Beta

Clue - Esoteric programming #4

Description:

Clue - Esoteric programming #4

Clue is a simple, cyclic esoteric programming language. A clue program is made up of 0s and 1s, the program can modify itself and is unknown if it is turning complete or not.

Task

You must implement the Interpreter function which returns an object that has two properties cycle and run. The function must be able to execute a valid Clue program and return the correct output for each iteration.

Properties

cycle will be a getter that must return the current iteration of the source code.

run is a function which must return a string of the current source code after it has been processed using the rules below.

Details

0 removes the last character of the string.

1 takes the next two characters, NANDs them (resulting 0 if both inputs 1, otherwise 1), and adds the result in the beginning of the string. The program pointer then moves to just beyond the second input that was read for NAND.

Example

For example, the program 110 would work the following way (x marks where the program pointer is currently):

1x 1 0 (1 and 0 is NANDed, the resulting 1 is placed in the beginning)

1x 1 1 0 (1 NAND 1, 0 added in the beginning)

0 1 1 1 0x (the last character is removed, thus the 0 removes itself)

0x 1 1 1 (the last character, 1, is removed)

0 1x 1 (1 NAND 0, 1 is added in the beginning -- and so forth...)

Reference

Fundamentals

Stats:

CreatedJan 24, 2016
PublishedMay 29, 2016
Warriors Trained80
Total Skips6
Total Code Submissions456
Total Times Completed23
JavaScript Completions23
Total Stars3
% of votes with a positive feedback rating68% of 11
Total "Very Satisfied" Votes7
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes3
Total Rank Assessments12
Average Assessed Rank
4 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • matt c Avatar
  • hufftheweevil Avatar
Ad