Собачка
A row of digits folds in on itself, pair by pair, until one digit is left.
Hakerh400, 2022 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Hakerh400 made Собачка in 2022. The program is a list of decimal digits and nothing else. Each round looks at every two neighbouring digits and writes down what they make. The new list replaces the old one, and the run ends when a single digit is left. That digit is the output. The specification conjectures that every program ends.
The machine
For each pair of neighbours a and b, in order.
| Case | Produces |
|---|---|
a + b is at most 9 | a + b |
otherwise, a = b | a |
otherwise, a < b | 1 and a + b - 10 |
| otherwise | nothing |
A list of n digits has n - 1 pairs, and each pair gives zero, one or two digits, so a list can shrink or grow. An empty list prints 0. Characters that are not digits are left out.
Example
The example takes 17 rounds.
The example takes 17 rounds. The first turns 22 digits into 23, as 4 and 8 make 1 and 2. The last rounds are 7277, 997 and 9. The list 12345 from the specification's Haskell becomes 3579, 81216, 9337, 610, 71 and 8.
Patterns it teaches
- String rewriting: one rule for every pair, applied to the whole list at once.
Further
See also
String-rewriting paradigm
Write your own in Run Convert a program from Собачка
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: u421-43e-431-430-447-43a-430.
Command line
shib run u421-43e-431-430-447-43a-430 -e '9'shib manual u421-43e-431-430-447-43a-430Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/u421-43e-431-430-447-43a-430.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org