We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

SHITS

From Esolang
Jump to navigation Jump to search

SHITS (Simple language witH bITS) is an esolang by User:ChuckEsoteric08 based on brainfuck minimalisations which uses binary tape.

Specification

Language uses right-infinite tape.

Commands

! - flip bit and move to the first cell
> - move right
{...} - while not zero

Optional I/O commands:

* - output bit
+ - input bit

Computational class

Language is Turing-complete, because it can simulate Cyclic Tag with initial string of 1:

Program start - !>>>!{
; - {>>}>>!{>>}!
0 - {>>}>{!!>>{>>}>>{>>}!>>{>>}}!{>>{>>}>!}!
1 - {>>}>{!!>>{>>}>>{>>}>!>>{>>}>>{>>}!>>{>>}}!{>>{>>}>!}!
Program end - }

It also proves that it is Turing-complete even with maximum nesting depth of 3.

Interpreter

In Python 3

def interpret_shits(program):
  brackets = match_brackets(program)
  if brackets is None:
    raise SyntaxError("brackets are unmatched")
  
  cells = set()
  cell_pointer = 0
  i = 0
  
  while i < len(program):
    c = program[i]
    
    if c == "!":
      cells ^= {cell_pointer}
      cell_pointer = 0
    elif c == ">":
      cell_pointer += 1
    elif c == "{":
      if cell_pointer not in cells:
        i = brackets[i]
    elif c == "}":
      if cell_pointer in cells:
        i = brackets[i]
    elif c == "*":
      print("1" if cell_pointer in cells else "0", end=" ")
    elif c == "+":
      if input() != "0":
        cells.add(cell_pointer)
      elif cell_pointer in cells:
        cells.remove(cell_pointer)
    
    i += 1

def match_brackets(program):
  temp = []
  result = {}
  
  for i, c in enumerate(program):
    if c == "{":
      temp.append(i)
    elif c == "}":
      if len(temp) == 0:
        return None
      matched = temp.pop()
      result[matched] = i
      result[i] = matched
  
  return result if len(temp) == 0 else None

In CDILOI

// ! - flip bit and move to the first cell
// > - move right
// {...} - while loop
// * - output bit
// + - input bit
INP RCODE
CONC @RDATA 0! RDATA
CONC @LDATA ! LDATA
CONC ! @NEST NEST
LBL CMD
IF @RCODE @A HALT
DEL @RCODE CMD RCODE
CONC @CMD @LCODE LCODE
IF @CMD ! FLIP
IF @CMD > RIGHT
IF @CMD * OUT
IF @CMD + INP
IF @CMD { SLOOP
IF @CMD } ELOOP
IF A A CMD
LBL FLIP
DEL @RDATA BIT RDATA
IF @BIT 0 SET1
IF @BIT 1 SET0
LBL SET1
CONC 1 @RDATA RDATA
IF A A LEFT
LBL SET0
CONC 0 @RDATA RDATA
IF A A LEFT
LBL RIGHT
DEL @RDATA BIT RDATA
CONC @BIT @LDATA LDATA
IF @RDATA ! NEWR
IF A A CMD
LBL NEWR
CONC 0 @RDATA RDATA
IF A A CMD
LBL LEFT
DEL @LDATA BIT LDATA
CONC @BIT @RDATA RDATA
IF @LDATA ! CMD
IF A A LEFT
LBL OUT
DEL @RDATA BIT RDATA
CONC @BIT @RDATA RDATA
OUT @BIT
IF A A CMD
LBL INP
DEL @RDATA BIT RDATA
INP BIT
CONC @BIT @RDATA RDATA
IF A A CMD
LBL SLOOP
DEL @RDATA BIT RDATA
CONC @BIT @RDATA RDATA
IF @BIT 0 FIND}
IF A A CMD
LBL FIND}
DEL @RCODE CMD RCODE
CONC @CMD @LCODE LCODE
IF @CMD { INCNEST1
IF @CMD } DECNEST1
IF A A CMD
LBL INCNEST1
CONC * @NEST NEST
IF A A FIND}
LBL DECNEST1
IF @NEST ! CMD
DEL @NEST CMD NEST
IF A A FIND}
LBL ELOOP
DEL @RDATA BIT RDATA
CONC @BIT @RDATA RDATA
IF @BIT 1 FIND{
IF A A CMD
LBL FIND{
DEL @LCODE CMD LCODE
CONC @CMD @RCODE RCODE
IF @CMD { INCNEST2
IF @CMD } DECNEST2
IF A A CMD
LBL INCNEST2
CONC * @NEST NEST
IF A A FIND{
LBL DECNEST2
IF @NEST ! CMD
DEL @NEST CMD NEST
IF A A FIND{
LBL HALT