Write a program that outputs

Do not repeat yourself!

Your program code must respect the following constraints :

  • its length must be an even number
  • each character that is in position 2n (where n is an integer > 0) must be equal to the character in position 2n-1. The second character of the program is equal to the first, the fourth is equal to the third, etc.

Newlines count as characters!

This is code-golf, so the shortest code wins!


HHeellllooWWoorrlldd is a valid program

123 or AAABBB or HHeello are incorrect


You can use this CJam script to verify that your source code is valid. Simply paste your code into the "Input" box and run the script.

  • 54
    \$\begingroup\$ Fun fact: If the problem had triplets instead, DDDooo nnnooottt rrreeepppeeeaaattt yyyooouuurrrssseeelllfff!!! would be a valid answer in Trigger \$\endgroup\$
    – Sp3000
    Sep 24, 2015 at 2:39
  • 15
    \$\begingroup\$ I thought this might be too restrictive, but the flurry of answers proves me wrong. Nice question! \$\endgroup\$ Sep 24, 2015 at 7:14
  • 1
    \$\begingroup\$ Could someone add a scoring snippet? I like having those, and I wish every question had them. \$\endgroup\$
    – mbomb007
    Sep 25, 2015 at 22:01
  • 1
    \$\begingroup\$ All the current answers are esoteric langs. I wonder if this is possible in a normal lang? \$\endgroup\$
    – DankMemes
    Sep 27, 2015 at 20:45
  • 1
    \$\begingroup\$ @trichoplax Too restrictive for: Python, ///, 0815, C, possibly others too... \$\endgroup\$ Sep 8, 2016 at 15:43

20 Answers 20


Hexagony, 166 126 124 bytes


Inserting the implicit no-ops and whitespace, this corresponds to the following source code:

       \ \ ; ; ; ; 3
      3 r r ' ' 2 2 D
     D . . ) ) ; ; ; ;
    ; ; o o ; ; } } e e
   o o \ \ @ @ n n ; ; ;
  ; e e ; ; ; ; a a s s &
 & ; ; u u o o ; ; ; ; . .
  \ \ \ \ ; ; t t e e . .
   p p ; ; t t ; ; ; ; .
    . r r ; ; ' ' l l .
     . ' ' ; ; ; ; . .
      ; ; } } f f . .
       } } y y . . .

I'm sure it's possible to shorten this even more, and maybe even solve it in side-length 6, but it's getting tricky...

How it works

enter image description here

Diagram generated with Timwi's Hexagony Colorer.

The code is completely linear. The \ right at the start redirects the IP into a diagonal, such that we don't need to worry about the doubled characters at all. The coloured paths are executed in the order orange/red, blue/grey, green, purple (when there are two paths of the same colour, the left-hand path is executed first, before wrapping around to the right-hand one).

If we ignore no-ops, mirrors and commands which are overridden by others, the linear code comes down to this:


Letters in Hexagony just set the current memory edge's value to the letter's character code. ; prints the current memory edge as a character. We use & to reset the memory edge to 0 and print a space with 32;. } moves to a different edge, so that we can remember the 32 for further spaces. The rest of the code just prints letters on the new edge, and occasionally moves back and forth with ';} to print a space. At the end we move to the space edge again with ', increment the value to 33 with ) and print the exclamation mark. @ terminates the program.

  • 4
    \$\begingroup\$ This is really impressive!!! \$\endgroup\$ Sep 24, 2015 at 18:34
  • \$\begingroup\$ How did you reach the conclusion that it’s possible in size 6 or even 5? I see size 7 as even only barely fitting. \$\endgroup\$
    – Timwi
    Sep 24, 2015 at 19:22
  • \$\begingroup\$ @Timwi 5 was probably a bit overambitious, but with the exception of a single ;, there is absolutely no reuse between character pairs in the code yet. The current code is pretty much the first thing that came to my mind, so I'm thinking if one tried hard enough, it should be possible to find a much more complicated solution which reuses the semicolons and maybe even some letters, to fit this into side length 6. \$\endgroup\$ Sep 25, 2015 at 14:22
  • \$\begingroup\$ To get to size 6, you’d have to save 36 characters compared to size 7. Even if you use the 6 unused slots you have at the moment, you’d still have to save 30. You can reuse every ; only once because you cannot traverse them horizontally. There are only 23 ;s in your code, and only 6 character repetitions (2×o, 1×t, 1×r, 2×e), giving only 29. Personally, this more than convinces me that size 6 is impossible... \$\endgroup\$
    – Timwi
    Sep 25, 2015 at 14:40

GolfScript, 130 84 76 bytes

22..!!..00)){{DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff}}``%%>><<[[33]]++

Try it online in Web GolfScript.

How it works

The GolfScript interpreter starts by placing an empty string on the stack.

22 # Push 22.
.. # Push two copies.
!! # Negate the last copy twice. Pushes 1.
.. # Push two copies.
00 # Push 0.
)) # Increment twice. Pushes 2.

   # STACK: "" 22 22 1 1 1 2

{{DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff}}

`` # Push a string representation of the string representation of the block.

   # This pushes "{{DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff}}" (with quotes).

%% # Take every second element of that string, then every element of the result.
>> # Discard the first element of the result. Repeat.
<< # Truncate the result to length 22. Repeat.
[[ # Begin a two-dimensional array.
33 # Push 33, the character code of '!'.
]] # End the two-dimensional array.
++ # Concatenate the empty string, the 22-character string and the array [[33]].

Concatenating an array with a string flattens, so the result is the desired output.


Unary, ~1.86 × 10222

Simple brainfuck -> unary answer. Very sub-optimal ;).

The program consists of an even number of 0’s; specifically:


of them.

Original brainfuck code:

  • 3
    \$\begingroup\$ Neither of the code blocks you've provided satisfy the double-up rule. What am I missing? \$\endgroup\$ Sep 24, 2015 at 7:43
  • 29
    \$\begingroup\$ @doppelgreener: The first block of "code" is simply a large number. Specifically, the number of 1s in the Unary program that outputs the requested string. The second code block is the BF program that was used to produce it. As the Unary program is completely made of 1s, it trivially satisfies the repetition requirement. \$\endgroup\$ Sep 24, 2015 at 7:53
  • 10
    \$\begingroup\$ Also the number of zeroes is (luckily?) an even number :-) \$\endgroup\$
    – Arnaud
    Sep 24, 2015 at 8:36
  • 1
    \$\begingroup\$ I’ve taken the liberty to edit the answer so that the number doesn’t look like it’s supposed to be the code. \$\endgroup\$
    – Timwi
    Sep 25, 2015 at 2:10
  • 2
    \$\begingroup\$ @Kametrixom it is a Golunar description of the Unary program. The Golunar program as written doesn't fulfill the conditions. \$\endgroup\$ Sep 27, 2015 at 16:16

Ruby - 2100 1428 1032 820 670 bytes

This assumes the output can be a return value from a function (it wasn't specified that the output needs to be to STDOUT)



The trick is to build the string from an empty string "" using the append operation << and the ASCII codes of the characters.

To get the numbers for the ASCII codes I'm trying to decompose the number into values I can easily generate. For example ASCII 90 is just 88+1+1, which is:

  • 88 is okay on it's own
  • 11**00 is 11^0, which is simply 1

Fortunately both ++ and -- would mean add in ruby, so I can write 90 as 88++11**00++11**00

There are some tricks to get to some numbers easier than just adding 1s, here is the code I'm using to generate the above (which includes all mappings I'm using):

d = "Do not repeat yourself!"

d.each_char do |c|
  print "(("

print '""'


d.each_char do |c|
  print "<<"
  num = c.ord
  while num != 0
    convert = VALUES.find{|val|val.first<=num}
    print convert.last
    num -= convert.first
    print "++" unless num == 0
  print "))"

I'm still thinking about other tricks to decrease the characters required to get to a number.

Note that if you use the -rpp flag, and add pp to the start of the code like so:


then for extra 2+4 bytes this can function as a fully complete program, but it will print an extra " before and after the required string:


$ ruby -rpp golf.rb
"Do not repeat yourself!"
  • \$\begingroup\$ Could you clarify why this is not fully compliant? It looks perfect to me, and even the pp gem is a double letter... \$\endgroup\$ Sep 9, 2016 at 9:16
  • 3
    \$\begingroup\$ @trichoplax: it's in the post: 1. additional " characters in output and 2. the need of the -rpp flag (which is not like --rrpp) \$\endgroup\$
    – SztupY
    Sep 9, 2016 at 9:56
  • 1
    \$\begingroup\$ This answer is cool but answers that do not meet the specifications are subject to deletion. \$\endgroup\$
    – Wheat Wizard
    Mar 1, 2017 at 14:53
  • 1
    \$\begingroup\$ @SztupY To be absolutely clear, it is site policy to delete responses that do not follow the rules of the challenge. \$\endgroup\$ Mar 1, 2017 at 16:12
  • 1

><>, 174 bytes











































Thankfully, in a sense the restriction doesn't apply vertically. However, the biggest problem is that we need to double every newline.

The code that runs roughly goes like this:

v            Redirect instruction pointer to move downwards
79*07b*p     Place a ? on row 77 before the first ;
"..."        Push "Do not repeat yourself!" backwards, riffled between spaces

[main loop]
~o           Pop a space and output a char
l1=?;        If there is only the final space left, halt
06b*.        Jump back to the start of the loop

Note that the program has no double spaces — when in string mode, ><> pushes spaces for empty cells. Conversely, however, this means that a solution using g (read single cell from source code) would be trickier, since what spaces are in the program become NULs when read.

(Note: This can be 50 bytes shorter if it terminates with an error, but I like it this way.)

  • 1
    \$\begingroup\$ The right tool for the job... \$\endgroup\$ Sep 8, 2016 at 15:39

Sclipting, 186 146 bytes



To be clear, there are three lines of code, the middle of which is empty, because the newline needs to be duplicated. The byte count is based on UTF-16 encoding.


The block of Korean characters at the start pushes the string "DDDof� \"\u0002nf�of�twG \"\u0002rw'efVpw\aefVaf\u0016twG \"\u0002yw�of�uwWrw'sw7efVlf�fff!\"\u0012". You will notice that every third character is a character we want; the rest is gibberish. Here’s why:

In Sclipting, two Korean characters encode three bytes. Thus, each Korean character effectively encodes 12 bits. To get a string starting with D, the first 8 bits have to be 0x44; the rest don’t matter, but since we have to repeat every character, the 12th to 20th bits are also going to be 0x44. Thus, we will have a value of the form 0x44n44n for some n, which decomposes into the three bytes 0x44 0xn4 0x4n.

For the o, which is 0x6F, we get the bytes 0x6F 0xn6 0xFn.

Since I’m lazy, I started by encoding "DDDooo nnnooottt (etc.)" and then replaced every other character with the previous, which is why I get 0x444444 = "DDD" for the D and 0x6F66F6 = "of�" for the o. The is there because 0xF6 by itself is invalid UTF-8 encoding.

Now, back to the program. The rest of the program proceeds as follows:

껢껢 — pushes the string ".\"�"

鎵鎵 — removes the last character twice, leaving us with "."

❶❶ — two duplicates. Stack now: [".", ".", "."]

合合 — concatenate twice. Stack now: ["..."]

Now, what I want to do next is use "..." as a regular expression so that I can match three characters from the original string at a time, using the 替...終 loop construct. However, since every instruction is duplicated, I need to have two such regular-expression loops nested inside each other, and if the stack underruns I get a runtime error. Therefore,

虛虛 — push the empty string twice

and then start the loops. This way, the outer loop iterates only once because it matches the regular expression "" against the string "", which yields a single match. The inner loop runs once for every match of "..." against the big string. The body of the loop is:

標標 — push two marks onto the stack. Stack now: [mark mark]

現現 — push two copies of the current regex match. Stack now: [mark mark "DDD" "DDD"]

併併 — concatenate up to the first mark. Stack now: ["DDDDDD"]

一一 — take first character of that string, and then (redundantly) the first character of that. Stack now has the character we want.

The inner loop ends here, so every match of the regular expression is replaced with the first character of that match. This leaves the desired string on the stack.

Then the outer loop ends, at which point the desired string is taken off the stack and the only match of "" in the string "" is replaced with it, leaving the desired string once again on the stack.

  • 3
    \$\begingroup\$ Umm... why didn't you use code format here? Is it the chinese characters? \$\endgroup\$ Sep 8, 2016 at 15:39
  • \$\begingroup\$ @EriktheOutgolfer I was wondering the same thing (and they are Korean characters, not Chinese). \$\endgroup\$ Mar 2, 2017 at 12:16
  • \$\begingroup\$ @KevinCruijssen I think there are some Chinese characters in there too. In fact, spec says that it uses Hangul for data and Chinese for instructions. \$\endgroup\$ Mar 2, 2017 at 12:34
  • \$\begingroup\$ @EriktheOutgolfer Ah, you're indeed right. I should have rtfm.. :) \$\endgroup\$ Mar 2, 2017 at 12:40

Labyrinth, 528 bytes

66))__vv          ..33::00&&__vv          ..44__99||__vv          ..33::00&&__vv            ..99))__vv            ..99))__vv      ..44__88$$__vv          ..22__99++__vv          ..22__99$$__vv            ..22__99))$$__vv      ..33__77$$__vv            ..33__vv

      ..44__99||__^^          ..11__99++__^^          ..44__88$$__^^          ..44((__88$$__^^      ..11))__99++__^^      ..99((__^^          ..33::00&&__^^          ..44__99||__^^          ..44((__88$$__^^            ..99))__^^          ..11__99$$((__^^    ..@@


The double newlines hurt, but at least this proves that it's doable!

Each character is printed one-by-one, first by forming the code point then printing a single char. The code points are formed by:

D 68  66))
o 111 44__99||
  32  33::00&&
n 110 11__99++
t 116 44__88$$
r 114 44((__88$$
e 101 99))
p 112 11))__99++
a 97  99((
y 121 22__99++
u 117 22__99$$
s 115 22__99))$$
l 108 33__77$$
f 102 11__99$$((
! 33  33


)(        Increment/decrement by 1 respectively
&|$       Bitwise AND/OR/XOR respectively
+         Add
:         Duplicate
_         Push zero
0-9       Pop n and push n*10+<digit>

The unusual behaviour of Labyrinth's digits is exploited in 33::00&&, which is actually

[33] -> [33 33] -> [33 33 33] -> [33 33 330] -> [33 33 3300] -> [33 32] -> [32]
     :          :             0              0               &          &

Each single char is printed with the mechanism




The xx exist only to pad the grid so that it's 5 high. First the __ push two zeroes, then we hit a grid rotation operator v. We pop a zero and rotate:

__ v

and again:

__ v



We then move rightwards to the . on the third row, thus executing the print command only once.

  • \$\begingroup\$ I love the trick you used to execute the print command only once. That’s extremely clever. \$\endgroup\$
    – Timwi
    Sep 25, 2015 at 5:05

CJam - 176 136 bytes


Thanks to Sp3000 for dividing my program size by two :-)


  • The codes HH77++, GG00++, ... compute the integer ascii code of the characters by adding numbers (for example: `HH77++' pushes 17, 17 and 77 on the stack, then add these 3 numbers)
  • the portion of code at the end ]]{{cc}}// loops through the ascii codes and convert them to characters.

Try it here

  • 1
    \$\begingroup\$ Did you generate this with a program? At the very least, the very end can be 33cc, but I'm sure there's better ways for some of the others \$\endgroup\$
    – Sp3000
    Sep 24, 2015 at 7:36
  • \$\begingroup\$ @Sp3000 yes, just ran a program that tried various combinations with ++. I haven't tried other operators... \$\endgroup\$
    – Arnaud
    Sep 24, 2015 at 8:05
  • 3
    \$\begingroup\$ Another note: instead of cc everywhere, do ]]{{cc}}// at the end \$\endgroup\$
    – Sp3000
    Sep 24, 2015 at 8:07

Self-modifying Brainf***, 72 bytes

Note that \x00 represents a literal NUL hex byte (empty cell). The source code is placed on the tape, left of the starting cell.

!!fflleessrruuooyy  ttaaeeppeerr  ttoonn  ooDD\0\0<<<<<<++[[<<]]<<[[..<<]]


!!fflleessrruuooyy  ttaaeeppeerr  ttoonn  ooDD  The string on the tape for easy printing
\x00\x00                                        A separator to make printing shorter
<<<<<<++                                        Change first '.' to '0' (comment)
[[<<]]<<                                        Move to separator, then left to string
[[0.<<]]                                        Print string

Also, before making this program, I was making one using only BF characters in the source. It's possible! It's also much longer, since for an odd ASCII value, I was going to create double the value, then divide by two. Somewhat shorter would be modifying the entire source to generate odd values to start with.

  • \$\begingroup\$ Won't this output DDoo nnoott rreeppeeaatt yyoouurrsseellff!! (double spaces)? I see two .s. \$\endgroup\$ Sep 29, 2016 at 13:47
  • \$\begingroup\$ @EriktheGolfer Time for you to read my answer. Change first '.' to '0'. I changed the explanation to show (again) that the first . is changed to a zero. \$\endgroup\$
    – mbomb007
    Sep 30, 2016 at 13:22

Jelly, 66 bytes

““DDoo  nn““oott  rreepp““eeaatt  yyoouurrss““eellff!!””ṛṛḷḷWWQQ€€

Try it online!


The program still works if you remove every second character.

Try it online!

How it works

““DDoo  nn““oott  rreepp““eeaatt  yyoouurrss““eellff!!”

returns an array of string. The literal begins with a , ends with a , and the strings are delimited internally by . The result is

["", "DDoo  nn", "", "oott  rreepp", "", "eeaatt  yyoouurrss", "", "eellff!!"]

The link's argument and the return value are set to this array of strings, then the remainder of the source code is executed.

<literal>”ṛṛḷḷWWQQ€€  Argument/return value: A (string array)

         ”ṛ           Yield the character 'ṛ'.
           ṛ          Select the right argument of 'ṛ' and A: A.
            ḷ         Select the left argument of A and A: A.
              W       Wrap; yield [A].
             ḷ        Select the left argument of A and [A]: A.
               W      Wrap; yield [A].
                Q     Unique; deduplicate [A]. Yields [A].
                 Q€€  Unique each each; for each string s in A, deduplicate s.

Gammaplex, 66 bytes


XX""!!fflleessrruuooyy  ttaaeeppeerr  ttoonn  ooDD""XXXXrrRREE

Gammaplex is a 2D language that uses the position of the first newline as the line length, and ignore all other newlines.


MSM, 270 160 bytes

!!'',,ff'',,ll'',,ee'',,ss'',,rr'',,uu'',,oo'',,yy'',,  '',,tt'',,aa'',,ee'',,pp'',,ee'',,rr'',,  '',,tt'',,oo'',,nn'',,  '',,oo'',,DD'',,......................

My first MSM program!

String output in MSM is done by pushing the individual characters onto the stack and joining them into a single string via ., e.g.


The number of . is one less than the number of characters. For Do not repeat yourself! we need 22 .s. Luckily this is an even number, so we have 11 doubles


Putting the letters in front of it requires some more effort. The pattern


does the trick for each character c. It evaluates as follows

cc'',,            push c (remember: commands are taken from the left and operate on the right)
c'',,c            push c
'',,cc            quote ' and push
,,cc'             pop
,cc               pop
c                 voilà!

We need 23 such patterns starting with !!'',, and ending with DD'',, followed by the 22 join commands ..


Befunge 98, 70 66 bytes

Try it online!

After my invalid answer, here's a better one that actually fits the challenge!

2200**xx""!!fflleessrruuooyy  ttaaeeppeerr  ttoonn  ooDD��""kk,,@@

(Thanks to Martin Ender for suggesting the use of ��, character 0x17, instead of 88ff++)


2200          Push 2, 2, 0, and 0 onto the stack
*             Multiply 0 and 0, yielding 0
*             Multiply 2 and 0, yielding 0
              The stack is now [2, 0]
x             Pop a vector off the stack and set the instruction pointer delta to that
              The instruction pointer is now skipping over every other character, since the delta is (2, 0)
"!f ... oD�" Push the string onto the stack, with the number 23 (number of characters in the string) at the top
k,            Pop characters off the stack and print them, 23 times
@             End the program
  • \$\begingroup\$ You can save four bytes by using an unprintable character (code point 23) inside the string instead of 8f+: tio.run/nexus/… \$\endgroup\$ Mar 2, 2017 at 12:48

Backhand, 54 bytes

vv""!!fflleessrruuooyy  ttaaeeppeerr  ttoonn  ooDD""HH

Try it online!

Since Backhand's pointer already moving at three cells a tick, all we need to do is decrease that to 2 using v

  • \$\begingroup\$ That is surprisingly surprising \$\endgroup\$
    – PkmnQ
    Jan 25, 2020 at 9:18

DC, 348 346 342 306 290 278 bytes

File dnr6.short.dc (without trailing newline):



$ dc < dnr6.short.dc 
Do not repeat yourself!

05AB1E, 100 58 52 bytes

-6 bytes thanks to Kevin Cruijssen

„„€€··™™……€€––  ……¹¹‚‚  ……––‚‚))εε##θθáá}}»»……!!θθJJ

Try it online!

„„€€·              # dictionary string "g do"
     ·             # double (no effect on strings)
      ™            # title case: "G Do"
       ™           # title case again (no effect)
……€€––             # dictionary string "tools not–"
                   # spaces necessary so "–…" isn't parsed as a dictionary word
……¹¹‚‚             # dictionary string "team repeat‚"
                   # spaces necessary again
……––‚‚             # dictionary string "j yourself‚"
)                  # wrap the entire stack in an array
 )                 # and again: [["G Do", "tools not–", "team repeat‚", "j yourself‚"]]
  ε        }       # for each:
   ε      }        #  for each:
    #              #   split on spaces: ["tools", "not–"]
     #             #   and again: [["tools", "not–"]]
      θ            #   get the last element: ["tools", "not–"]
       θ           #   and again: "not–"
        á          #   keep only letters: "not"
         á         #   and again (no effect)
            »      # join the list by newlines, joining sublists by spaces:
                   # "Do not repeat yourself"
             »     # join the stack by newlines, joining lists by spaces (no effect)
……!!               # literal string "…!!"
    θ              # get the last character: "!"
     θ             # and again (no effect)
      J            # join the stack without separators: "Do not repeat yourself!"
       J           # and again (no effect)
                   # implicit output

Idempotency rules.

  • 1
    \$\begingroup\$ Nice answer, I'm impressed you were able to squeeze in the dictionary strings like that! It's unfortunately that á doesn't vectorizes on the inner strings, otherwise it could be used after the )).. Removing all á and using εεáá}} after the )) works as alternative, but unfortunately it doesn't save any bytes (but maybe you can find inspiration from it?).. And „„!! instead of ……!! work as well, since the ! builtin leaves the strings the same apparently. Ah well, I tried. xD \$\endgroup\$ Sep 4, 2019 at 13:00
  • 1
    \$\begingroup\$ @KevinCruijssen I've been trying to refactor those repeated ##θθáá for a while, and for some reason I didn't consider εε}}... I tried €€, which doesn't quite work... This is now the shortest answer, thanks! \$\endgroup\$
    – Grimmy
    Sep 4, 2019 at 13:08

BotEngine, 6x49=294

vv  PP
























>>  ^^

reticular, noncompeting, 62 bytes

2200**UU""DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff!!""oo;;

Try it online!

Explanation in parts:

2200    the stack looks like [2 2 0 0]
    *   [2 2 0*0]
     *  [2 2*0*0]
        [2 0]

U sets the pointer direction to (2, 0), that is, moving 2 x-units and 0 y-units, so it skips every other character, starting with the next U being skipped. Then, every other character is recorded, and it is equivalent to:

"Do not repeat yourself!"o;

which is a simple output program.


This is competing for WallyWest's JavaScript bounty:

I can prove that, while numbers can be constructed under this restriction, strings cannot. Since no literals can be used, as the placement of any literal-building character would create an empty string:


Then, only some operator can be used; the only "paired" operators used are:

++ -- << >> ** ~~ || && !! ==

And none of these can cast numbers/others to strings. So no strings can be outputted.


Alice, 74 bytes

aa00tt,,JJ""DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff!!//@@""ooYY;;tt

Try it online!


The first catch is that we need to be able to enter the string, so we want to skip only the first ". We do this by jumping onto the first " because then the IP will move one cell before looking at the current cell again, so that it's the second " which enters string mode. But to be able to jump there, we need 10, 0 on top of the stack, in that order (second, top). This is done with aa00tt,,:

aa   Push two 10s.        [... 10 10]
00   Push two 0s.         [... 10 10 0 0]
tt   Decrement twice.     [... 10 10 0 -2]
,    Rotate(-2).          [... 0 10 10]
,    Rotate(10).          [... 0 10 0]

This rotation function pops an argument. If that argument is negative, it pushes the value on top of the stack down by that many positions. If the argument is positive, it goes looking for the element that many positions below the top and pulls it up to the top. Note that in the case of Rotate(10), there aren't enough elements on the stack, but there is an implicit infinite amount of zeros at the bottom, which is why a zero ends up on top.

Now we can Jump onto the first " using these two arguments. The second " enters string mode and records all of that DDoo nnoott.... When it hits the /, the IP is redirected southeast and we enter Ordinal mode. For now on the IP bounces up and down across the three lines (two of which are empty), so it first records three more spaces on lines two and three and then we leave string mode when it hits the ". Since we're in Ordinal mode at this time, all the recorded characters are pushed as a single string to the stack (even though we recorded most of them in Cardinal mode), so we end up with this string (note the trailing spaces):

DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff!!   

Now the IP keeps bouncing up and down which means that it executes one command of every other pair, i.e. Y and t. Then the IP will hit the end of the grid on the second line and start bouncing backwards through the grid. This also switches in which pair of characters the IP hits the first line, so when going back it now executes ;, o and @. So ignoring all the spaces and implicit IP redirections, the executed code is Yt;o@ in Ordinal mode.

The Y is the "unzip" command which separates a string into the characters in alternating positions. Since each character is repeated, that really just gives us two copies of the string we're going for, although the first copy has two trailing spaces and the second has one trailing space. t splits off that trailing space and ; discards it. Finally, o prints the string and @ terminates the program.


Stax, 70 bytes

GG11hh::zzaapp..}}..""DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff!!""

Run and debug it at staxlang.xyz!

Stax very fortunately has the builtin :: for every-nth. All I need to is push the string doubled, push 2, and run ::. Easy, right?


Pushing that string is tricky. The first quotation mark can be doubled by .."", which is a length-2 literal for ." followed by a meaningful quotation mark. Problem is, I see no way to terminate the string (which is necessary, or else the doubled version will be printed) without starting a new one.

The end of the program terminates string literals. If I can put this doubled literal there, perhaps there'll be a nice workaround. To jump somewhere from the end of a program, however, requires G}, so at minimum, I'm looking at this:

GG [deduplicate] }}""DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff!!""

This does... nothing. G does not begin a block, so neither will jump to the second }. Again, I need to ignore one character: ..}}. Execution jumps from the first G to the second }, continues to the end, jumps back to the second G and from there to the second }, and continues once more to the end before resuming at the start of the [deduplicate] section with the doubled string atop the stack.

Deduplication is simple. 11hh pushed eleven and halves it twice, rounding down both times and yielding two, and :: will then get us the output we need.

GG11hh::..}}..""DDoo  nnoott  rreeppeeaatt  yyoouurrsseellff!!""

Uh-oh. This prints nothing. There are two problems here: first, that ..} means the string .} will be atop the stack at the end of the program, and second, Stax's ordinary implicit output is now disabled!

The worse issue is the output. When a Stax program terminates gracefully without printing anything, the top of the stack will be implicitly printed. But we haven't printed anything...? Ah, but we have. Unterminated string literals are printed rather than pushed, and even those two empty strings (from the unmatched " at the end), despite being empty, are enough to trip this check. Any printing must be done by hand.

We'll need either pp or PP, and in this instance, ignoring the first through ..pp is unacceptable, as it will print the string .p. That means we need our desired output either alone on the stack or in the top two along with an empty string. This latter is accomplished by pushing two empty strings (zz) and rotating the top three items twice (aa) before printing.

Once that's done, we have a stack four strings tall. A fifth, .}, is then pushed before the program exits gracefully; at this point, the lack of implicit output becomes a blessing as well as a curse, as nothing extra will now be printed!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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