From Esolang
Jump to navigation Jump to search

BrainSoothe (abbreviated BS in a G-rated context) is an esolang devised by User:arseniiv in 2020 entirely not for mocking the abbreviation BF.


The program is a nonempty finite sequence of (unbounded) nonnegative integer literals delimited by spaces or other non-numeric characters which are ignored. There should be no literals at different positions which denote the same number.


At runtime, there is an unbounded integer register initialized to the program input, or to zero if there’s no input. There is a literal pointer which can point to any literal in the code; initially it points to the leftmost one. We denote the value of the literal currently in focus by and the current value of the register by .

Each execution step, we assign and test if . If that’s the case, we make , then jump literals to the right, and in case of overshoot, halt. If that’s not the case, we just shift focus to the literal to the right of the current, and if that’s not possible, jump to the first literal.

The output is the final value of the register when the execution halts.


That literary description above might be misleading against all my wishes, so here is a more formal one in Python 3 (you may ignore the import and erase type annotations if you wish).

from typing import Sequence

def run(instructions: Sequence[int], value: int) -> int:
    instr_count = len(instructions)
    assert instr_count != 0
    assert all(instr >= 0 for instr in instructions)
    assert instr_count == len(set(instructions))
    instr_index = 0
    while True:
        value += 1
        instr = instructions[instr_index]
        test = value % instr if instr != 0 else value
        if test == 0:
            value -= instr
            instr_index += instr
            if instr_index >= instr_count:
                return value
            instr_index += 1
            if instr_index == instr_count:
                instr_index = 0


A single-instruction program implements floor division , including the case of for which it doesn’t halt.


If this ends up being a language simple to write in, or a non-TC one, well, that was worth a try, as I admit this joke language was fleshed out in less than half an hour.

Update: Yes that’s not TC as the register effectively has values. Meh.