Rotpai
A row of two-character tiles that turn round or slide past each other until none of them can turn.
Mipinggfxgbtftybfhfyhfn, 2019 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
The esolangs.org user Mipinggfxgbtftybfhfyhfn made Rotpai in 2019. A program is a row of character pairs like ab cb cd. Where the last character of one pair is the first of the next, the two pairs meet. A pair that meets nothing turns round, a pair that meets on one side changes places with that neighbour, and a pair that meets on both sides stays. The row stops when no pair is left that meets nothing.
Read the story
The specification calls its computational class unclear, most likely a finite state automaton. A row of n pairs has only so many arrangements, so every run either stops or repeats.
The machine
| Pair meets | Does |
|---|---|
| Neither neighbour | Turns round, ca becomes ac |
| One neighbour | Changes places with it |
| Both neighbours | Stays |
An end at the edge of the row always meets. A step goes through the pairs from left to right and changes the row as it goes. Each line is a row of its own, unless its last pair ends in .; then the next line joins it.
Rotpai has no input or output. This implementation prints every state of each row, one per line, from the first to the last.
Example
cb meets neither ab nor cd, so it turns round into bc.
cb meets neither ab nor cd, so it turns round into bc. Now every pair meets a neighbour, and the run stops after one step.
The second example ends its first line in ., so both lines make one row of four pairs.
It prints these four states.
a. b. d. .e
a. .b .e d.
.b .e a. d.
.b e. .a d.
In the second step .b swaps left with a., and then .e meets the a. that just arrived and swaps with it too. So a. moves two places in one step, as in the specification.
Further
See also
Also in Rewriting
Write your own in Run Convert a program from Rotpai
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: rotpai.
Command line
shib run rotpai -e 'a.
bc'shib manual rotpaiSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/rotpai.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org