How to resolve the algorithm Narcissist step by step in the Icon and Unicon programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Narcissist step by step in the Icon and Unicon 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 Icon and Unicon programming language
Source code in the icon programming language
procedure main();yes:="Accept";no:="Reject";pat:="procedure main();yes:=$;no:=$;pat:=$;a:=[yes,no,pat];narc:=char(0)[0:0];pat?{while narc||:=tab(find(char(36))) do{narc||:=image(get(a));move(1)};narc||:=tab(0)};write(if read()==narc then yes else no);end";a:=[yes,no,pat];narc:=char(0)[0:0];pat?{while narc||:=tab(find(char(36))) do{narc||:=image(get(a));move(1)};narc||:=tab(0)};write(if read()==narc then yes else no);end
You may also check:How to resolve the algorithm XML/XPath step by step in the Rascal programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Lang programming language
You may also check:How to resolve the algorithm Equilibrium index step by step in the Ada programming language
You may also check:How to resolve the algorithm Bitcoin/address validation step by step in the C programming language
You may also check:How to resolve the algorithm Partition an integer x into n primes step by step in the Go programming language