Skip to content

Instantly share code, notes, and snippets.

@hornc
Last active May 12, 2026 13:04
Show Gist options
  • Select an option

  • Save hornc/ae55ac0219c6e70e893f582c86f2cd00 to your computer and use it in GitHub Desktop.

Select an option

Save hornc/ae55ac0219c6e70e893f582c86f2cd00 to your computer and use it in GitHub Desktop.
Grill Tag interpreter in Python (~92bytes)
# Grill Tag interpreter in Python with datastring viewer argument o=:
# https://esolangs.org/wiki/Grill_Tag
# _p_roductions (standard RLE * 2), _d_atastring: {-1: '1', 0: '0', n*2: '01'*n + '0'}
def gtag(p,d,o=print,c=0):
while d:o(d);d+=[p[c%len(p)]]*(d[0]&1);d[0]-=1;d=d[d[0]<0:];c+=1
from grilltag import gtag
"""Usage Examples:"""
# Using this interpreter's own custom RLE (standard * 2): Equivalent to: ([0,1,1], "110110")
gtag([0, 2, 2], [-1, -1, 0, -1, -1, 0])
# With internal datastring representation output as binary:
gtag([0, 2, 2], [-1, -1, 0, -1, -1, 0], lambda s: print(''.join(['1' if v<0 else ('01'*((v+1)//2)+'0')[v&1:] for v in s])))
# Convert standard RLE and initial strings as arguments, with binary output:
gtag([v*2 for v in [0, 1, 1]], [-int(b) for b in "110110"], lambda s: print(''.join(['1' if v<0 else ('01'*((v+1)//2)+'0')[v&1:] for v in s])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment