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.
!4warning

!4warning is a semi-serious output-only esolang. The name is a reference to xkcd: Random Number that evaluates against a Varnier scale.
Varnier scale

The Varnier scale is used as a ruler and can be rendered in graphing software. K describes a set of relations on x and y.

sin(10πx)>0
1<=y<=2
0<=x<=1
sin(12πx)<0
0<=y<=1
0<=x<=1
sin(10πx)=0
sin(11πx)=0
0<=y<=2
0<x<1
constant K
The field which is measured by the ruler can be described as the constant K.
| K= |
|---|
| 9452238590691318544677168576033200183352173863084085276275318211522354628763231360594706925388931138237215903222640767476400096069360530679935418459808368481610046763719747994227425913987337684765737036791110892391349802789451832819115487656320269576779073664600607318227318393653996155130791134302835878212423809302964077062823416265983444183318323940373872544663585781871588799140913348455312641602507741670812876131572546595553483686993258289946963100336958037351963177619919832712526811720379511912110879890167484262879803610293602475520 |
put
To perform the principal function (print):
- !4warning compares a portable bitmap file with a P1 magic header against K.
- If k = K print 4.
- else: intervals = abs(k - K) // 17
- print(chr(intervals % 128))
You could print any other ascii by evaluating the set of files given here.
interpreter
import sys
K = int(
"94522385906913185446771685760332001833521738630840852762753182115223546287"
"63231360594706925388931138237215903222640767476400096069360530679935418459"
"80836848161004676371974799422742591398733768476573703679111089239134980278"
"94518328191154876563202695767790736646006073182273183936539961551307911343"
"02835878212423809302964077062823416265983444183318323940373872544663585781"
"87158879914091334845531264160250774167081287613157254659555348368699325828"
"99469631003369580373519631776199198327125268117203795119121108798901674842"
"62879803610293602475520")
W, H = 106, 17
def read_pbm(data: bytes):
"""Parse P1 (ascii) or P4 (raw) PBM. Returns list of rows of 0/1."""
if data[:2] == b'P1':
toks = data[2:].split()
w, h = int(toks[0]), int(toks[1])
bits = ''.join(t.decode() for t in toks[2:])
px = [int(c) for c in bits if c in '01']
if len(px) < w*h:
raise ValueError(f"P1 data too short: {len(px)} < {w*h}")
return [px[r*w:(r+1)*w] for r in range(h)]
if data[:2] == b'P4':
# header: P4 <ws> w <ws> h <single ws> raw rows, each padded to a byte
i, fields = 2, []
while len(fields) < 2:
while data[i] in b' \t\r\n': i += 1
j = i
while data[j] not in b' \t\r\n': j += 1
fields.append(int(data[i:j])); i = j
i += 1 # single whitespace before raster
w, h = fields
rb = (w + 7)//8
rows = []
for r in range(h):
chunk = data[i + r*rb : i + (r+1)*rb]
row = []
for c in range(w):
row.append((chunk[c >> 3] >> (7 - (c & 7))) & 1)
rows.append(row)
return rows
raise ValueError("not a P1/P4 PBM")
def tupper_k(rows):
h = len(rows); w = len(rows[0])
if h != H:
raise ValueError(f"bitmap must be {H} rows tall, got {h}")
if w > W:
raise ValueError(f"bitmap wider than {W} columns ({w})")
# narrower images sit at the left of the 106-column frame; rest is blank
n = 0
for r in range(h):
for c in range(w):
if rows[r][c]:
x, y = (W - 1) - c, (H - 1) - r
n |= 1 << (17*x + y)
return 17 * n
def main(argv):
data = open(argv[1], 'rb').read() if len(argv) > 1 else sys.stdin.buffer.read()
k = tupper_k(read_pbm(data))
if k == K:
print(4)
else:
intervals = abs(k - K) // 17
print(chr(intervals % 128))
if __name__ == '__main__':
main(sys.argv)