Your job is quite simple, write a program that prints Hello, world!, that when twisted creates a program that prints Twister!.

How strings are twisted

The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It kinda looks like this:


With everything under the line wrapping to the top. Real example:



(Further examples and a twisters in your favorite language are here)


Your program must be a padded rectangle. This is code-golf so lowest byte count wins!


  • Your first program must print Hello, world!. Only one trailing newline is allowed.
  • Your first and second programs must be in the same language.
  • Your second program must print Twister!. Only one trailing newline is allowed.
  • Your program must have at least 2 rows and 2 columns.
  • 2
    In Jelly's code page, the character that corresponds to (and, for all purposes, acts like) the linefeed has the code point 127 (ASCII DEL). The character with code point 10 (ASCII linefeed) has the glyph ½ and takes the square root of a number. Which one of the two should be considered the newline for this challenge? – Dennis Feb 2 '16 at 23:26
  • Darn, was I the only one that hoped "Twisted Hello World" was using "twisted" in the perverse sense so we'd be outputting something like "Goodbye Cruel World" instead.. – DasBeasto Feb 3 '16 at 13:49
  • @Dennis I suppose the better one to use in this case would be the jelly newline. – J Atkin Feb 3 '16 at 14:17
  • @JAtkin OK, thanks for clarifying. I've updated my answer accordingly. – Dennis Feb 3 '16 at 17:45
up vote 9 down vote accepted

Jelly, 33 31 29 bytes



Try it online.



Try it online!

How it works

In each program, each line defines a link. The last one is the main link, and it is executed when the program starts. Since there are no references to the first link, it is simply ignored.

For both programs, “ɗ⁻%OḶ$“¡¦ḟṠ» yields the list ['Hello, world!', 'Twister!'], using Jelly's static dictionary compression.

The only difference between the original and the twisted code is the last character of the main link. selects the first string of the list, and selects the last one.

  • 2
    It looks like it's screaming "Holy Sh*t" – phase Jun 22 '16 at 19:49

Python 2, 59 bytes

print "  Hello, world!"[ 2::]
#rint "T w i s t e r !"[ ::2]


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.

  • This is so much smarter than my approach – wnnmaw Feb 2 '16 at 22:20
  • This is kinda ridiculous, 40 upvotes? – J Atkin Feb 18 '16 at 17:24
  • @JAtkin I've noticed that some Python solutions tend to get huge amounts of them. Not that I'm complaining :~) – Pietu1998 Feb 18 '16 at 19:18
  • Cooler way: print " Hello, world!" [2::] – Erik the Outgolfer Jun 15 '16 at 14:48
  • @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Works, but I'll just keep it as is for now. – Pietu1998 Jun 15 '16 at 16:39

Fission, 215 162 56 53 50 bytes

Here is a start:


Try it online!

When twisted:


Try it online!


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 next 1 in reading order, retaining its direction (that's the one next to the r).
  • 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 the 1.
  • Now the portal sends the atom to the next 1. The atom hits the o which just changes its mass, but we can ignore that. The code wraps around so the atom hits the same 1 again, skipping down two rows. Again, we can ignore the l, the atom wraps around and hits the 1 again. Now there is no further 1 in the code so the atom skips all the way back to the 1 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.
  • Wow, very close now! :) I'm sure there's a way to be shorter... – FryAmTheEggman Feb 2 '16 at 18:48
  • Why do you guys like fission? – J Atkin Feb 2 '16 at 18:57
  • @JAtkin Why wouldn't we? :) – Martin Ender Feb 2 '16 at 18:59
  • @MartinBüttner I was thinking specifically why for this challenge? – J Atkin Feb 2 '16 at 19:02
  • 1
    @JAtkin 2D languages seemed suitable, and Fission seemed particularly simple because you can choose one or more arbitrary entry points into the program. – Martin Ender Feb 2 '16 at 19:03

Fission, 35 bytes

Fission approach #3 (#4 counting the one I edited out of my first post).

R"Hello, " \"tri"

Try it online!

R;H"ldor w /"er!"

Try it online!


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.

  • Amazing! I think this is about as small as it can get, the amount of reuse is impressive. – FryAmTheEggman Feb 2 '16 at 22:26

Fission, 53

R"Hello, world!";

Try it online!

and twisted:

.;H..l.. "!re"!/.

Try it online!

Japt, 67 61 57 bytes

Saved 6 bytes thanks to @JAtkin, 4 bytes thanks to @Ian

"Hzezlzlzoz,z zwzorlzdz!"rz;


"Hzezlzlzoz,z zwzorlzdz!"rz;

Test it online: Original, Twisted

How it works

"Tzwzizsztzezzzzzzrzzzz!"rz;  // Take this string and remove all "z"s.
"Hzezlzlzoz,z zwzorlzdz!"rz;  // Take this string and remove all "z"s.
                              // Implicit: output *last* expression
  • If this works like I think it does, you can remove the trailing space after Twister! by replacing the spaces with .. – J Atkin Feb 2 '16 at 21:29
  • @JAtkin It actually doesn't work like that, but I can save a bunch of bytes that way. Thanks! – ETHproductions Feb 2 '16 at 21:33
  • "T.w.i.s.t.e.r.!. . . . . "k".(newline)"H.e.l.l.o.,. .w.o.r.l.d.!"k". – J Atkin Feb 2 '16 at 21:36
  • Could be much easier to read with a different filler character... – mbomb007 Feb 3 '16 at 18:35
  • 4
    @mbomb007 Since when is "easy to read" an achievement? :D – yo' Feb 3 '16 at 19:20

Python, 398 414 380 456 bytes*

Managed to update so that it is compliant with the rules, but I still hesitate to call this competitive. Since the commented lines are needed for it to run, I've included them in the byte count

This solution does not follow the rules, as it will print error messages in addition to the allowed output.

I just wanted to see if this could be done in python. It can, but it is not pretty.

print'Hello, world!'

When twisted becomes

#rint'Twiste !'
#rint'Twister!' l
#rint'Twister!'  d
#rint'Twister!'   !
  • I think you could remove the space in each line, then remove the last line altogether. – ETHproductions Feb 2 '16 at 21:15
  • I didn't think to do that since it was against the rules of the initial twisting challenge, but thanks! – wnnmaw Feb 2 '16 at 21:18
  • You forgot to update the code ;) – ETHproductions Feb 2 '16 at 21:25
  • I figured it wouldn't really matter, but I did it for good measure – wnnmaw Feb 2 '16 at 21:29
  • 1
    I think you have misunderstood. The code is required to be a padded rectangle, but you can remove the space from rint ' on every line. – ETHproductions Feb 2 '16 at 21:29

C (gcc), 87 bytes


main(){puts(1?"Hello, world!":"Twister!");}
mai (){puts(0?"Hello, world!":"Twister!");}

Try it online!


mai (){puts(1?"Hello, world!":"Twister!");}
main(){puts(0?"Hello, world!":"Twister!");}

Try it online!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.