How to resolve the algorithm Narcissist step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Narcissist step by step in the J programming language

Table of Contents

Problem Statement

Quoting from the Esolangs wiki page: For concreteness, in this task we shall assume that symbol = character. The narcissist should be able to cope with any finite input, whatever its length. Any form of output is allowed, as long as the program always halts, and "accept", "reject" and "not yet finished" are distinguishable.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Narcissist step by step in the J programming language

Source code in the j programming language

#!/usr/bin/ijconsole
main=:3 : 0  NB. tested under j602
  self=: '#!/j602/bin/jconsole',LF,'main=:',(5!:5<'main'),LF,'main''''',LF
  echo  self -: stdin''
)
main''


$ ./narcissist.ijs <narcissist.ijs
1


   narcissist=.(-:,~,2#{:)&'(-:,~,2#{:)&'''


   (-:,~,2#{:)&'(-:,~,2#{:)&''' '(-:,~,2#{:)'
0
   (-:,~,2#{:)&'(-:,~,2#{:)&''' '(-:,~,2#{:)&''(-:,~,2#{:)&'''''''
1


  

You may also check:How to resolve the algorithm Idoneal numbers step by step in the PL/M programming language
You may also check:How to resolve the algorithm Catalan numbers/Pascal's triangle step by step in the Run BASIC programming language
You may also check:How to resolve the algorithm Five weekends step by step in the NetRexx programming language
You may also check:How to resolve the algorithm Bitmap/Bézier curves/Cubic step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Pancake numbers step by step in the AWK programming language