User:Dragoneater67/wipwipwip/67 machine

From Esolang
Jump to navigation Jump to search

67 machine is a minimalist esoteric programming language created by User:Dragoneater67.

Overview

The language only has 2 instructions:

  • 6 flips the next instruction and jumps 7 steps forward
  • 7 appends the previous instruction to the end of the program and jumps 6 steps back

The program runs infinitely and wraps around so that out-of-bounds jumps are impossible.

Examples

Looping counter

7

Interpreters

Python

code = "7"
code = list(code)
a = 0

while True:
    print(''.join(code))
    c = code[a]
    if c == '6':
        code[(a+1)%len(code)] = ('7' if code[(a+1)%len(code)] == '6' else '6')
        a = (a + 7) % len(code)
    elif c == '7':
        code.append(code[(a-1)%len(code)])
        a = (a - 6) % len(code)
    else:
        pass

C++

#include <iostream>
#include <string>

int mod(int a, int b) {
    return ((a % b) + b) % b;
}

int main() {
    std::string code = "67";
    int ip = 0;
    
    while (true) {
        std::cout<<code<<std::endl;
        char c = code[ip];
        switch (c) {
            case '6':
                code[mod((ip + 1), code.length())] = (code[mod((ip + 1), code.length())] == '6' ? '7' : '6');
                ip = mod((ip + 7), code.length());
                break;
            case '7':
                code.push_back(code[mod((ip - 1), code.length())]);
                ip = mod((ip - 6), code.length());
                break;
            default:
                break;
        }
    }
}