Width
Only letters count, and each letter means the digit of how wide it is.
stestoltz · Turing complete: unknown · ●●● hard
Tested with 6 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Width sorts the 52 letters into ten classes by their printed width, from the thin i j l (0) to the wide W (9). Everything that is not a letter is thrown away, so a program can hide inside ordinary text. The interpreter is a Python 3 script.
Read the story
The digit decides what a letter does. Classes 2, 5 and 6 are the ternary digits 0, 1 and 2 of a command, so ww is command 22, print. A class 3 letter separates two commands.
The machine
| Digit | Letters | Does |
|---|---|---|
| 0 | i j l | Loop while the counter is not 0 |
| 1 | f r t I | End a block |
| 2 5 6 | c k s ..., A B E ..., w C D ... | Command digits 0, 1, 2 |
| 3 | a b d e ... | Separator |
| 4 | F T Z | A number, up to the same letter |
| 7 | G O Q | A string, two letters per character, up to the same letter |
| 8 | m M | If the top is true |
| 9 | W | Else |
There are about a hundred commands on Python values for arithmetic, strings, a counter, a second stack called the backburner. A command that hits an empty stack quietly does nothing. Nothing is printed at the end; the top item becomes the exit code.
Example
FKF is 5 and FwF is 6; swA is command 021, multiply, and ww prints.
FKF is 5 and FwF is 6; swA is command 021, multiply, and ww prints. The last one sets the counter to 3 with ss, then loops; each round pushes the counter, prints it and counts down.
Patterns it teaches
- Camouflage: punctuation, digits and spaces are ignored, so a program can be written as prose.
- Encoding tricks: a letter's meaning is its shape.
Try this
- Read a number and print it doubled (command 1012).
- Print the numbers 5 to 1.
- Hard: write a Hello World that reads as an English sentence.
Further
- The reference interpreter, width.py and info.txt
See also
Also in Golfing
Write your own in Run Convert a program from Width
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: width.
Command line
shib run width -e 'Acaww' --input '21
'shib manual widthSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/width.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language