Lesbianburger

From Esolang
Jump to navigation Jump to search

Lesbian burger is a self-modifying language written by User:Gwepz. The program has a list of symbols which it uses for many things, which is as follows " abcdefghijklmnopqrstuvwxyz0918273645" (whitespace included)

It stores data in its commands, and its two integers 'acc' and 'pos'.

When a program is run, all commands are shifted in the afformentioned list of symbols by their position in the program, where the first command is shifted along 1 place, the second command by 2 places, and so on and so forth.

The valid commands are:

'a', Which adds 1 to the program 'acc', which stands for 'accumulator'

'b', Which adds 1 to the program 'pos' mod the program length. 'pos' stands for 'position'.

'c', Which integer-halves the number in the accumulator, rounding down.

'd', Which sets the command at 'pos' to the corresponding symbol in afformentioned symbols list.

'f', Which prints the command at 'pos'.

'g', Which sets the code pointer to the pos.

'h', Which skips to the corresponding 'i' (e.g hbhbibi would go the last i, as the h and i in the middle correspond to eachother) if the accumulator is 0, else it starts a loop.

'i', Which returns back to the corresponding 'h'. (the loop can only be broken by self modification)

'j', Which does nothing, but adds to a counter that gets displayed at the end of the program as the 'laziness score'.

'k', which sets the command at 'pos' to user input.

Interpreter:

with open("code.txt", mode='r') as f: code = list(f.read())
letters = list(" abcdefghijklmnopqrstuvwxyz0918273645")
ct, new, acc, pos, lazy = 0, [], 0, 0, 0
stack = []
for i in code:
    new.append(letters[(letters.index(i)+ct+1)%len(letters)])
    ct += 1
ct = 0
while ct < len(new):
    if new[ct] == "h":
        if acc == 0:
            t1, t2 = ct, 0
            while t2 < 1:
                if new[t1] == "h": t2 -= 1
               elif new[t1] == "i": t2 += 1
               t1 += 1
           ct = t1 + 1
           continue
       else: stack.append(ct)
   elif new[ct] == "i": ct = stack[-1]
   elif new[ct] == " ": break
   elif new[ct] == "a": acc += 1 #+1 acc
   elif new[ct] == "b": pos = (pos + 1)%len(new)
   elif new[ct] == "c":
       t1, t2 = acc, 0
       while t1 > 1: t1, t2 = t1 - 2, t2 + 1
       acc = t2
   elif new[ct] == "d": new[pos] = letters[acc]
   elif new[ct] == "f": print(new[pos],end=)
   elif new[ct] == "g": ct = pos
   elif new[ct] == "j": lazy += 1
   elif new[ct] == "k": new[pos] = input()
   ct += 1
print("the laziness score of this program is " + str(lazy))