Quebe

From Esolang
Jump to navigation Jump to search

Quebe (Queue of Bytes) is an esolang which is inspired by ResPlicate by User:ChuckEsoteric08

Description

Quebe uses a queue made out of bytes and has initial state which is an nonempty string.

Execution

At each step, a symbol is dequeued (let's call it x) and enqueue string starting at the front a queue to n, where n is how many times x appears in the queue after it was dequeued. If n is zero or it's bigger than length of a queue execution stops

Examples

bbaabba
 baabbabaa
  aabbabaaaab
   abbabaaaababbaba
    bbabaaaababbababbabaaaa
     babaaaababbababbabaaaababaaaaba
      ...

Python implementation

def quebe(string):
    while True:
        front = string[0]
        string = string[1:]
        occurrences = string.count(front)
        if occurrences == 0 or occurrences > len(string):
            break
        string = string + string[:occurrences]