Double Helix
The program is a drawing of DNA. Its two strands take turns editing one string of bits.
Hakerh400, 2020 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Hakerh400 made Double Helix in 2020. The source is a double helix drawn in text, with exactly the spaces and dashes of the drawing. Every line holds one nucleotide of each strand, and where the strands cross they change sides.
Read the story
Input and output are bits. The program edits one main string, which starts as the input. It runs until it comes back to a state it was in before, and what the string holds then is the output. Thespecification guesses that this is as strong as a pushdown automaton, but nobody has proved it.
The machine
| Nucleotide | Does |
|---|---|
A | Append 0 |
C | Append 1 |
G | Reverse the string |
T | Remove the last bit; if it was 1, change strand |
Each step reads the nucleotide on the current strand and line, moves on one line, wrapping around at the end, and then does what it says. A state is the string, the strand and the line. The run halts when a state comes a second time.
Example
The cat.
The cat. A appends a 0 and T takes it off again, so after two steps the state is back with the input untouched.
The bit reverser. Strand 0 reads G C T T and strand 1 reads T A T A. G reverses the string. C and T push and pop a 1, and popping a 1 moves the run to strand 1, where A and T push and pop a 0 for ever. Four steps later the state is back.
Patterns it teaches
- Camouflage: a program has to look like DNA, down to the number of dashes on each line.
Further
See also
Also in Camouflage
Write your own in Run Convert a program from Double Helix
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: double-helix.
Command line
shib run double-helix -e 'A------------------A
T------------------A' --input '1011'shib manual double-helixSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/double-helix.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org