Ttttt

From Esolang
Jump to navigation Jump to search

Now if you want to know how Ttttt works, go to Tttt, because who doesn’t like go to statements. The 2 differences between Tttt and Ttttt is that Tttt has three memory slots, Ttttt uses infinite. Also Tttt has no nested loops. Ttttt does.

Hello, world

Most programs are the same. This is hello, world.

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaeabaaaaaaaaaaaaaaeabaaae
eabaebbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbebbbbbbbbbbbbeabaa
aaaaaaaaaaaaaaaaaaaaaaaaaeaaaa
aaaaaaaaeabaebbbbbbebbbbbbbbeb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbe

So yeah.

The one line version is:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaeabaaaaaaaaaaaaaaeabaaaeeabaebbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbebbbbbbbbbbbbeabaaaaaaaaaaaaaaaaaaaaaaaaaaaeaaaaaaaaaaaaeabaebbbbbbebbbbbbbbebbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbe

This nested loop program wouldn't work in Tttt, not only because it has three nested loops, but because if there were only three spaces possible, even if it could cycle through the spaces indefinitely, it would be incrementing and decrementing the same spot at the same time.

aaiccaaiccaaiccaadbjdbjdbjccccccbe

It outputs ÿ.

Implementations

This is an implementation in Python, but it is not the official implementation.

def run_ttttt(data: str) -> None:
    code = list(data)
    variables = [0, 0, 0]
    pointer = 0
    which_var = 0

    while pointer < len(code):
        if 'a' == code[pointer]:
            variables[which_var] += 2
        elif 'b' == code[pointer]:
            variables[which_var] -= 1
        elif 'c' == code[pointer]:
            which_var += 1
            if which_var == len(variables):
                variables.append(0)
        elif 'd' == code[pointer]:
            which_var -= 2
            while which_var < 0:
                variables = [0] + variables
                which_var += 1
        elif 'e' == code[pointer]:
            print(chr(variables[which_var]), end="")
        elif 'f' == code[pointer]:
            print(variables[which_var], end="")
        elif 'g' == code[pointer]:
            print("\n", end="")
        elif 'h' == code[pointer]:
            variables[which_var] = ord(input())
        elif 'i' == code[pointer]:
            if variables[which_var] == 0:
                nest_counter = 0
                while code[pointer] != 'j' or nest_counter >= 0:
                    pointer += 1
                    if code[pointer] == 'i':
                        nest_counter += 1
                    elif code[pointer] == 'j':
                        nest_counter -= 1
                    elif code[pointer] == 'k':
                        pointer += code[pointer:].index('l')
        elif 'j' == code[pointer]:
            if variables[which_var] != 0:
                nest_counter = 0
                while code[pointer] != 'i' or nest_counter >= 0:
                    pointer -= 1
                    if code[pointer] == 'j':
                        nest_counter += 1
                    elif code[pointer] == 'i':
                        nest_counter -= 1
                    elif code[pointer] == 'l':
                        while code[pointer] != 'k':
                            pointer -= 1
                pointer -= 1
        elif 'k' == code[pointer]:
            pointer += code[pointer:].index('l')
        pointer += 1