Build a twisted "Hello world!"
Python 2, 59 bytes
print " Hello, world!"[ 2::]
#rint "T w i s t e r !"[ ::2]
Twisted:
print "T weils,twerrd!"[ ::2]
#rint " H l o o l !"[ 2::]
Basically, puts the Twister!
data in the odd indices of the string and then changes from removing the first two (padding) characters to removing every other character instead.
Fission, 215 162 56 53 50 bytes
Here is a start:
D1
\\
""
TH
we
il
sl
to
e,
r
!w
"o
1r
;l
1d
;!
"
Try it online!
When twisted:
D"
\1
"\
T"
wH
ie
sl
tl
eo
r,
!
"w
1o
;r
1l
;d
!
Try it online!
Explanation
The Hello, world!
code is fairly simple:
D
spawns a single atom, going downwards.- The two
\
(mirrors) deflect it onto the second column. "Hello, world!"
prints the required string.1
is a portal. It teleports the atom to the next1
in reading order, retaining its direction (that's the one next to ther
).- The atom still moves down, into the
;
which destroys the atom and terminates the program.
The control flow for the Twister!
code is a bit more... twisted...
- Again,
D
spawns the atom. \
deflects it to the right, into the1
.- Now the portal sends the atom to the next
1
. The atom hits theo
which just changes its mass, but we can ignore that. The code wraps around so the atom hits the same1
again, skipping down two rows. Again, we can ignore thel
, the atom wraps around and hits the1
again. Now there is no further1
in the code so the atom skips all the way back to the1
at the top. - After wrapping around the edges once more, the atom is deflected again by
\
, now going down again. "Twister!"
prints the required code.1
teleports the atom once more, past the first;
, but there is another;
waiting for it to terminate the program.
Fission, 35 bytes
Fission approach #3 (#4 counting the one I edited out of my first post).
R"Hello, " \"tri"
T;L"!dlrow"/"es!w
Try it online!
R;H"ldor w /"er!"
T"Le!ll,o""\"tsiw
Try it online!
Explanation
This one is actually the simplest of the Fission solutions yet. In both programs there are two entry points: R
creates a right-going atom and L
a left-going atom. In either case, the ;
destroys one of them immediately.
Now in the Hello, world!
program, the atom first prints half the string with "Hello, "
, then \
and /
(which are mirrors) deflect the atom onto the second line going left. "world!"
(read in the direction of the moving atom) prints the rest of the string. L
is now a no-op and ;
destroys this atom as well, terminating the program.
The Twister!
program is essentially the same but rotated by 180 degrees. This time, the L
atom survives, and starts printing with "Twist"
. The \
and /
again deflect it onto the other line, now going right. "er!
prints the remainder of the string, R
is a no-op and ;
terminates the program.