Tttt

From Esolang
Jump to navigation Jump to search

Intro

what is Tttt?

Tttt is a programming language that is so simple that it has 10 characters: 1.) a 2.) b 3.) c All the way to j.

the data

The data is kind of like brainfuck, an array of cells, 3 in the original, and infinite in Ttttt. There is a pointer, also like brainfuck.

the symbols

  1. a gets the cell under the pointer and adds 2 to it. Why 2? So it is inefficient!
  2. b gets the cell under the pointer and subtracts 1. There is no limit for cells. -infinity to +infinity.
  3. c pushes the pointer forward by one.
  4. d pushes the pointer backward by two.
  5. e prints the ascii character of the cell under the pointer.
  6. f prints the value of the cell under the pointer.
  7. g prints a new line.
  8. h does a brainfuck (ASCII) input.
  9. i is a brainfuck ‘[‘.
  10. j is a brainfuck ‘]’.

k and l can be used for comments. Example:

k this is a comment l.

programs

Hello, World!

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaeabaaaaaaaaaaaaaaeabaaae
eabaebbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbebbbbbbbbbbbbeabaa
aaaaaaaaaaaaaaaaaaaaaaaaaeaaaa
aaaaaaaaeabaebbbbbbebbbbbbbbeb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbe

That took me a while to make. One line:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaeabaaaaaaaaaaaaaaeabaaaeeabaebbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbebbbbbbbbbbbbeabaaaaaaaaaaaaaaaaaaaaaaaaaaaeaaaaaaaaaaaaeabaebbbbbbebbbbbbbbebbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbe

Truth-machine

hchdcicbdcbjcifjf

You need two inputs. The first one is zero. The second one is 1 or 0.

aaaicaaaacdbjhcibcdbcjcdifjf

You only need one input for this truth machine, which can be either 0 or 1.

Implementations

This is an implementation in Python which works with the examples above. However, it is not the official implementation.

def run_tttt(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
        elif 'd' == code[pointer]:
            which_var -= 2
        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:
                while code[pointer] != 'j':
                    if code[pointer] == 'k':
                        pointer += code[pointer:].index('l')
                    pointer += 1
        elif 'j' == code[pointer]:
            if variables[which_var] != 0:
                while code[pointer] != 'i':
                    if code[pointer] == 'l':
                        while code[pointer] != 'k':
                            pointer -= 1
                    pointer -= 1
                pointer -= 1
        elif 'k' == code[pointer]:
            pointer += code[pointer:].index('l')
        pointer += 1