ETC

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

ETC, standing for both "etc." and ETC and ETC, is a minimalist esolang, created by user:Elbereth, with only 3 commands excluding NOP: E, T, C.

E 

increments counter by 1;

T 

multiplies counter by 2;

C 

jump to command with position same as the counter. However, if the counter points to the same location, to prevent an infinite loop, it acts as E but also prints the ASCII/Unicode character represented by value of the counter.

All other characters are NOP; The standard form is .

Note the counter increments are done modulo the program size, which means that infinite loops are still possible and very easy to make, for example:

CCCTC

Computational class

ETC is a FSA, because you only need to store the counter modulo (1114111*the program size) to store all information you need. however, if you need to store the accumulator, it's easy to prove that a normal PDA can't cope with the case, making it sub-Turing-complete.

Examples

XKCD Random Number

ettttteeeeeeeeeeeeeeeeeeee                          Chosen by fair di e roll. Guarenteed to be random.

etc.py

program = input('Program: ').upper()
index = 0
counter = 0
while index < len(program):
    if program[index] == 'E':
        counter += 1
    elif program[index] == 'T':
        counter *= 2
    elif program[index] == 'C':
        if index == counter:
            print(chr(index), end="")
            counter += 1
        else:
            index = counter - 1
    index %= len(program)
    counter %= len(program)
    index += 1