We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Unthree star programmer

From Esolang
Jump to navigation Jump to search

Unthree star programmer is an esolang invented by user:cleverxia, inspired by Three Star Programmer. where you decide the number of dereferences instead of the dereferenced address.

Syntax

A program here is just a cyclic infinite sequence of positive numbers. (you may just input the instructions in one period, and repeat the program indefinitely.)

Program flow

This language operates on a infinite array of cells. All cells have value 0 when the Unthree star programmer program starts.

When each number is executed as an instruction, say the number is x, it executes

**...**((void*)3)++;

where there are x stars. This is the only instruction and thus this language is an OISC.

(optional) incrementing cell 5 halts the program, incrementing cell 6 outputs cell 2 as a character, incrementing cell 7 outputs cell 2 as a number, incrementing cell 8 inputs to cell 2.

If we let function D(x,y)=(y==0?x:*(D(x,y-1))) then Three Star Programmer can be seen as D(x,3)++; for each instruction x, and this esolang can be seen as D(3,x)++; thus the name.

Examples

infinite loop

1

null program

1 1 1 1 1 2

cat program

1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 1 2 2 2 2 2 2 3

Computational class

Unthree star programmer is Turing complete because it is possible to compile Three Star Programmer (without I/O, which is not required for Turing-completeness) into it. A simple way to do such a compilation is to translate a Three Star Programmer command n to 1 1 1 2 1 1 1 1 1 1, followed by 9n copies of 2, followed by 9 copies of 5.

This translation stores the Three Star Programmer tape using every ninth element of the Unthree star programmer tape, and uses the rest of the Unthree star programmer tape as temporaries. The primary invariant behind the construction is: between the commands, cell 3 of the Unthree star programmer tape is always congruent to 1 (mod 9), except at the start of the program when it is 0, and all tape cells (except possibly those whose positions are 0 (mod 9)) to the right of the cell that cell 3 points to are 0. When cell 3 is congruent to 1 (mod 9), 1 1 1 2 1 1 1 1 1 1 will increase cell 3 by 9, while adding 1 to the value of a cell whose position is congruent to 4 (mod 9), which does not break the invariant (and cells whose position is congruent to 4 (mod 9) are never read during the construction). Meanwhile, when 1 1 1 2 1 1 1 1 1 1 is run from the program's initial state, it sets cell 3 to 10 (which is congruent to 1 (mod 9)) and makes no other changes (the 1s directly increment cell 3, and the 2 indirectly increments cell 3 because its value is 3 at the time). In either case, the invariant is preserved, and additionally, cell 3 ends up pointing to a cell whose value is 0. At this point, 2 commands are used to increment the target of cell 3 to become 9n, and then 9 5 commands are used to increment ***n by 9 (as each command increases it by 1). This therefore ends up simulating the Three Star Programmer tape using every ninth element of the Unthree star tprogrammer tape, with all the elements multiplied by 9; and because Unthree star programmer can simulate a Turing-complete language, it must itself be Turing complete.

Interpreter in js

a=[2];
b=0n;e={};while(1){c=a[+(b++%BigInt(a.length)+"")];d=3n;while(--c)d=e[d]||0n;e[d]=(e[d]||0n)+1n;
    if(d==5n)process.exit();
    if(d==6n)process.stdout.write(String.fromCharCode(+(e[2n]+'')));
    if(d==7n)process.stdout.write((e[2n]+'')));
    if(d==8n)throw"input not supported!"
}