Create a program, that outputs a hello world string ("Hello world", "Hello, World" etc.), and source code. Output is written to stdout or equivalent. Hello world string is embedded in the source code.

For example, the output for might be

(some source code here)hello world(some source code here)

When the output is compiled or interpreted again, it should create a similar output, but the hello world string must have a different punctuation or capitalization. For example, the previous example could create the following output

(some source code here)hello, wORld(some source code here)

Each "(some source code here)" in these examples can change after each execution, or it can be the same.

Your output must contain a valid hello world string exactly once. It may contain any amount of invalid hello world strings. Source code may contain any amount of comments, and the hello world string may be embedded in comments. The first program can have either zero or one valid hello world strings, but no more.

Following punctuation is valid:

hello, world
hello world

Any capitalization is acceptable. For example, these are valid hello world strings:

Hello, world
hellO WORld

These strings are not valid:

Hello     world
Hello, Steve

Your program fails as soon as one of the following conditions are met:

  • It outputs a hello world string that has been output during some earlier execution,
  • output is no longer valid source code in the same language, or
  • output does not contain exactly one valid hello world string.

Your program is not valid for this contest unless at least two first executions are successful. This means that the third output is allowed to be invalid. Output of your program may not be random. First execution should always create the same second output, second execution should always create the same third output, etc.

Score is calculated as amount of bytes in the source code of the initial program. Lowest score wins.

Following bonuses do apply (up to -60%):

  • -5% * (N - 2), where N is the index of the execution after which your program produces invalid output. This bonus caps at -50%. If your program succeeds 12 times or more, you get the max bonus.
  • -10%, if your outputs (including first source code) include all three valid punctuation alternatives.

Your submission should include the first source code, and it should also contain the outputs of the successful executions. If your program succeeds more than 12 times, add output for 12 executions.


Next line is the first source code. When we execute it, it is the first execution.

hello world(some source code here)

Next line is the output from the first source code code. It is the first output.

hello, world(some source code here) 

Next line is the output from the second execution. It is the second output.

helloworld(some source code here)

When we executed the first output, this program became eligible for the -10% bonus. That means we have two outputs, and one original code, which all have different punctuation. Moreover, because the second output was valid, this program is eligible for this contest.

Next line is the output from the third execution. It is the third output.

Helloworld(some source code here)

Next line is the output from the fourth execution. It is the fourth output.

hellworld(some source code here)

This output was invalid. Index of the last valid execution was 4. This program is eligible for -5% * (4 - 2) bonus and -10% bonus from the punctuation. This makes total of -20%. The length of the first source code ("hello world(some source code here)") was 34 bytes, so the final score is 27.2.

  • 1
    \$\begingroup\$ Do the usual quine rules apply or is the program is allowed to read its own source file? \$\endgroup\$ Commented Nov 5, 2015 at 10:36
  • 1
    \$\begingroup\$ Usual quine rules do apply. \$\endgroup\$
    – user46926
    Commented Nov 5, 2015 at 10:38
  • \$\begingroup\$ Does the original code count towards the bonuses? Likewise, does the original code have to contain a valid hello world? \$\endgroup\$ Commented Nov 5, 2015 at 15:13
  • 1
    \$\begingroup\$ Original code counts towards bonuses. Original code does not have to contain a valid hello world. \$\endgroup\$
    – user46926
    Commented Nov 5, 2015 at 16:10
  • \$\begingroup\$ Are you sure about that latest rule change? Together with "The first program does not have to contain a valid hello world string, or it may contain multiple valid hello world strings." I could add the missing variations as a comment to the original source code to get the bonus (probably not worth it in most cases but still looks like a loophole) \$\endgroup\$ Commented Nov 5, 2015 at 16:22

18 Answers 18


Mathematica, 214 194 - 50% = 97 bytes

(a = "helloworld"; b = Apply[StringJoin, Tuples[Thread[Characters[{ToLowerCase[a], ToUpperCase[a]}]]], {1}]; StringReplacePart[ToString[#0, InputForm], b[[FirstPosition[b, a] + 1]], {7, 16}]) & 

I decided to optimize for string count here. This runs for 1024 programs without stopping, going through every combination of uppercase and lowercase letters. The execution can be seen here.

  • 1
    \$\begingroup\$ A shame that you can't golf out whitespace and use prefix and infix notation in Mathematica quines, isn't it? ;) (This might be long enough for the opposite quine approach to work, where you store the code in a string s, and evaluate it with ToExpression.) \$\endgroup\$ Commented Nov 5, 2015 at 13:54
  • \$\begingroup\$ If I weren't trying to hit 1000, I'd drop a +100 bounty here. \$\endgroup\$ Commented May 26, 2021 at 11:29

Pyth, 17 bytes

A different Pyth solution:




Second output:

  • \$\begingroup\$ Rules currently state "Your program fails as soon as one of the following conditions are met: output is no longer valid source code in the same language" and "Your program is not valid for this contest unless at least three first executions are successful.". Is HELLOWORLD a valid program in Pyth? If yes, please post its output as well or explain what it does. If not, I think this program is invalid. \$\endgroup\$
    – user46926
    Commented Nov 6, 2015 at 11:38
  • \$\begingroup\$ Additionally, I want to clarify that this program does not break rules about repeating the same string. This solution repeats "helloworld" that was in the first source code. Rules only forbid repeating a string that has been in the previous outputs. If the second output is a valid Pyth program, then this solution is perfectly valid. \$\endgroup\$
    – user46926
    Commented Nov 6, 2015 at 11:39
  • \$\begingroup\$ At the time of answering, the rules were "Your program is not valid for this contest unless at least two first executions are successful" \$\endgroup\$ Commented Nov 6, 2015 at 11:41
  • \$\begingroup\$ Oh, you are right. I'm not sure why I have changed that because my example in the first post states that two outputs = valid solution. I will correct the rules to reflect this. So your solution is valid. It is also the best valid solution at the moment. \$\endgroup\$
    – user46926
    Commented Nov 6, 2015 at 11:49
  • \$\begingroup\$ Beaten by 2 bytes in 5 years. Lol \$\endgroup\$
    – Makonede
    Commented Jan 18, 2021 at 19:57

Vitsy, 33 - 33*.05*(11-2) = 18.15 Bytes

Heh! Beat that! You probably will. :c

First output:

'                                 Start capturing as a string
 0DV                              Push 0 to the stack and set it as the final variable.
    \                             Repeat the next item this many times. (1, 2, 3... on outputs.)
     {                            Rotate the stack leftwards.
      25^                         Push 32 to the stack.
         -                        Subtract the top item by it - this will make lowercase uppercase.
          V\                      Do the next item final variable times.
            }                     Rotate the stack rightwards.
             }                    And again...
              1+                  Add one. This makes the 0 in this code a 1, then 2...
                r                 Reverse the stack.
                 d3*              Get the character '
                    Z             Output all items in the stack.
                     ;            End execution.
                      helloworld  String to manipulate.

Second output:


Third output:


Fourth output:


Fifth output:


Sixth output:


Seventh output:


Eighth output:


Ninth output:


Tenth output:


Eleventh output:


This is the last output, as it will cause an error.

  • 1
    \$\begingroup\$ o_o Simplex struggled down to 21. I'll work on beating 18.15, though! \$\endgroup\$ Commented Nov 5, 2015 at 18:54
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ Vitsy was practically built to edit its own source code and do basic string manipulation. XD I think this can be golfed down more, though. \$\endgroup\$ Commented Nov 5, 2015 at 19:09
  • \$\begingroup\$ I thought simplex would be awesome, since it has an outer program function, but noooo that would count as one program. le sigh \$\endgroup\$ Commented Nov 5, 2015 at 19:14
  • \$\begingroup\$ +1 for beating (or almost beating) the "classic" golfing languages \$\endgroup\$
    – user46167
    Commented Nov 5, 2015 at 22:48
  • \$\begingroup\$ @ev3commander I would've beaten them if the iteration bonus was higher. :c \$\endgroup\$ Commented Nov 6, 2015 at 15:16

CJam, N = 3 4, 28 bytes - 10 % - 10 % = 22.4

{`_E=-"_~Hello!, World"2<}_~

this starts the following chain:

{`_E=-"_~Hello, World"2<}_~
{`_E=-"_~Hello World"2<}_~

where the last one no longer contains a valid "Hello, World".

Test it here.


{`     e# Quine framework. Leaves a string representation of the block on the stack.
  _E=  e# Make a copy and get the 14th element, which is the character of the first 'o'.
  -    e# Remove that character from the string.
  "_~Hello!, World" e# Push this string, so the "Hello, World!" is part of the code.
  2<   e# Truncate to just "_~" to get the output right.  

Note that the initial program does not contain a valid "Hello, World", but that allows us to go one iteration further.

  • \$\begingroup\$ Does this qualify for the -10% bonus? The outputs only contain two of the three valid punctuation forms. \$\endgroup\$ Commented Nov 5, 2015 at 14:38
  • \$\begingroup\$ @MikeBufardeci Oh good question... I sort of assumed the original code was part of it. \$\endgroup\$ Commented Nov 5, 2015 at 15:13
  • 1
    \$\begingroup\$ I clarified rules so that original code is counted for the bonus. Though I have to admit I did not realize it is this easy to get -10%. \$\endgroup\$
    – user46926
    Commented Nov 5, 2015 at 16:13

CJam 69 60 - 50% = 30

I'm still beginner, Please tell me how to golf in CJam.


It's tedious to print each iteration, as it will valid for 99 iterations.

It works by enumerate the capitalization of hello word. The tedium is to splitting strings into parts as both "hello world" and the counter have to be updated.


{`                                                                      e# standard quine framework. Thanks for Dennis.
  _40>                                                                  e# get the Yb11..
      \40<                                                              e# get those that not included in top
          _38>~)`2Te[                                                   e# get the accumulator and increment it
                     \25<                                               e# get those before "hello world"
                         "helloworld"                                   e# the Hello World
                                     00                                 e# accumulator
                                        YbATe[                          e# convert to binary and align right.
                                              .{{el}{eu}?}              e# Uppercase if the corresponding bit is 0
                                                          `             e# add quote
                                                           +]W%         e# reorder stack

NOTE: I don't read the Mathematica answer, sorry, I think it was original

With reordering, and different capitalization, I lose 9 bytes.

{`                                                   "_~"}_~ e# Standard quine framework
  _6<\                                                       e# Get "{~_6<\"
      "helloworld"                                            e# The helloworld
                  01                                          e# The accumulator
                    Yb                                        e# Convert to base 2
                      W%                                      e# Reverse the binary
                        .{{eu}{el}?}                          e# Convert to uppercase while the corresponding bit is 1.
                                    `                         e# Add quote
                                     _2<                      e# Get accumulator
                                        ~)`2Te[               e# Increment the accumulator
                                               \2>            e# get the rest

CJam 73 - 60% = 29.2

This time also enumerate the punctuation.

{`:Z6<"HELLOWORLD"0:AYbW%.{{eu}{el}?}`", ":B-_6<BA3%>@6>A)ZW%52<W%"_~"}_~
{`:Z                                                              "_~"}_~ e# Standard Quine Framework
    6<                                                                    e# take the first 6 character
      "HELLOWORLD"                                                        e# Hello, world
                  0:A                                                     e# Accumulator
                     YbW%.{{eu}{el}?}`                                    e# See above
                                      ", ":B                              e# Punctuation
                                            -                             e# Delete punctuation
                                             _6<                          e# "hello
                                                BA3%>                     e# punctuation
                                                     @6>                  e# world"
                                                        A)                e# incremented accumulator
                                                          ZW%52<W%        e# Remaining part
  • \$\begingroup\$ You have a different language and a shorter answer, so there's nothing wrong using same approach as the Mathematica answer. \$\endgroup\$
    – user46926
    Commented Nov 5, 2015 at 13:35
  • \$\begingroup\$ Note that we are looking for the lowest score, not the fastest poster or the most novel algorithm. \$\endgroup\$
    – user46926
    Commented Nov 5, 2015 at 13:40
  • \$\begingroup\$ @Ville-ValtteriTiittanen Still, Martin Büttner's answer is still lower than me \$\endgroup\$
    – Xwtek
    Commented Nov 5, 2015 at 13:42
  • 1
    \$\begingroup\$ @ChristianIrwan Yours is interesting because it produces different capitalisations though (and I'm sure it's golfable to get near mine or maybe even beat it, but I don't have the time to look at it in detail right now). \$\endgroup\$ Commented Nov 5, 2015 at 13:53

GolfScript, 35 bytes − 50% = 17.5


I decided to go for overkill on the number of executions before a repeat. This program, with its output fed back into the GolfScript interpreter, will produce 890 distinct Hello World strings before the first repeat. As a brief sample, here are the first 15 iterations:


The way it works is by iterating through the string, flipping the capitalization of each letter (by XORing its ASCII code with 32) if the previous letter (after possibly having its case flipped) is lowercase. The first letter will have its case flipped if the number at the beginning program is 32 rather than 0 — and the number output for the next iteration will be 32 whenever the last letter of the string is lowercase, thus causing any changes at the end of the string to propagate back to the beginning on the next iteration.

(This particular feedback process was obtained in a totally ad hoc manner. I originally wanted to just run a simple binary counter using uppercase and lowercase as the bits, but that took too many bytes to implement, so I started tweaking it to find something shorter that would still yield a fairly high cycle length. Since the theoretical maximum, using case-flipping only, is 210 = 1024, getting an 890-iteration cycle is pretty nice.)

Alas, the bonus for additional iterations is capped at −50%; without the cap, this program would have a whopping −4440% bonus. ;-)

  • \$\begingroup\$ This is the "gray code" (wiki link here). I originally was going to use this for my answer, but I couldn't see how I could possibly make it short. Nicely done \$\endgroup\$ Commented Feb 26, 2021 at 22:03
  • \$\begingroup\$ @SamuelWaller: This isn't actually Gray code. In Gray code only one bit would flip on each iteration and it would take 1024 iterations for the 10-bit sequence to loop back to its starting value. My sequence satisfies neither of those properties. \$\endgroup\$ Commented Feb 26, 2021 at 23:15
  • \$\begingroup\$ you are correct, the conversion method from binary to Gray code is by xoring each digit with the one to the left of it, which is similar enough to what you are doing I got confused. Still, nice answer! \$\endgroup\$ Commented Feb 26, 2021 at 23:43

Pyth, 18 bytes

"-\"hello world\"d

Which returns:

-"hello world"d

Which in turn prints:


I had a solution that did all three spellings, but it's longer even with the bonus.

  • \$\begingroup\$ Note that this answer was invalid briefly until the rules were reverted to requiring two iterations rather than three. It is now valid again, though. \$\endgroup\$
    – DLosc
    Commented Nov 6, 2015 at 23:33

Ruby, 81 - 50% = 40.5

Original code:

_='_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)';puts _%[_,'HELLOWORL'+?D]

Successive outputs:

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"HELLOWORLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"hELLOWORLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"heLLOWORLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"helLOWORLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"hellOWORLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"helloWORLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"hellowORLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"hellowoRLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"helloworLD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"helloworlD"]).sub(/[[:upper:]]/,&:swapcase)

_="_=%p;puts (_%%[_,%p]).sub(/[[:upper:]]/,&:swapcase)";puts (_%[_,"helloworld"]).sub(/[[:upper:]]/,&:swapcase)

I think this counts as the full 50%? Might be off by one. Also, there's probably a better-scoring non-bonus solution in Ruby.

The original code doesn't contain "helloworld", but it builds a quine that replaces the first capital letter in its source code with the lowercase version. So each successive run of the quine outputs one fewer capitalized letter.

The trick here is to use a format string to interpolate both the string itself, for quining, and the Hello World string, so that it only appears once.


Simplex, 21 bytes.

This is what Simplex was born for. I can definitely go farther with this.

(I keep on hitting Ctrl+Enter, sorry! I blame it on the tablet keyboard)

Attempt 3, v.0.8+, 31 -5% = 29.45 bytes (UTF-8 methinks)

That emote in the middle expresses myself. Sort of. Why did I do this, again? ._.

"                            "  ~~ write that string
 \"f[helloworld]-:D-``\"§R'Hg   ~~ escaped quotes
                              g ~~ output that string

2nd Output:

"                   "      ~~ write that string
 f[helloworld]-:D-``       ~~ string to be written
                     §R    ~~ go to second cell
                       'H  ~~ set it to H charcode
                         g ~~ output that string

3rd output:

f                   ~~ turns off safety mode (heck yeah error suppression!)
 [          ]-      ~~ write inside to outer program
  H                 ~~ sort strip
   e                ~~ write e = 2.718281828459045... to the strip
    ll              ~~ writes 1 twice to the cell
      o             ~~ outputs 1
       wo           ~~ apply o backwards through the strip (outputs 1)
         r          ~~ error! tries to access register for modification. nope!
          l         ~~ write 1 to to the current cell
           d        ~~ reverse the strip (NOP)
              :     ~~ removes last char of outer program
               D    ~~ double the current byte (2)
                -   ~~ writes previous char to outer program
                 `` ~~ suppress outer program evaluation and instead output it

Final output:


Attempt 2, v.0.8+, 21 bytes (UTF-8, I think)

"                  "  ~~ write that string
 \"helloworld\"§'Hg   ~~ escaped quotes
                    g ~~ output that string


"          "     ~~ write that string
 helloworld      ~~ string to be written
            §    ~~ go to first cell
             'H  ~~ set it to H charcode
               g ~~ output that string

Final output:


Attempt 1, v.0.7+ 28 26 bytes

I'm not sure if this qualifies for the first bonus…

"            "             ~~ write that string
 BhelloworldB              ~~ the string
              t[     ]     ~~ apply the inner from left to right
                s          ~~ output as character
                 32S       ~~ subtract 32 ("capitalize")
                    ;      ~~ add the current byte's char to the outer program
                      'g;s ~~ add g to the outer program

First output:


The outer program is evaluated at the end of execution (it does it for y; this is what the outer program looks like:

"          "  ~~ write that string
            g ~~ output that string as string characters

Final output:

  • \$\begingroup\$ Is this program eligible for the -50% bonus? It looks like it could be, but you did not post any outputs. \$\endgroup\$
    – user46926
    Commented Nov 5, 2015 at 16:53
  • \$\begingroup\$ @Ville-ValtteriTiittanen It only runs twice. I am working on bonuses at the moment. \$\endgroup\$ Commented Nov 5, 2015 at 18:07

Vyxal, score 8


Try it Online!


kh#Hello, World! 

Try it Online!


Hello World



Push the string "kh#" onto the stack (which, when literally executed, is the constant "Hello World" and a comment)


Push the string "Hello, World!" onto the stack and concatenate the two strings together. Implicitly print the string.


PHP, 297 - 40% = 178.2 bytes

Not really competitive but it was fun to write

<?ob_start(function($s){$s=substr(str_replace(0,0+(int)true,$s),!i,ord(I)+ord(I));$h=hello.world;$h[0]=$h[0]^' ';return "<"."?".$s."?".">".$s.$h;});?>ob_start(function($s){$s=substr(str_replace(0,0+(int)true,$s),!i,ord(I)+ord(I));$h=hello.world;$h[0]=$h[0]^' ';return "<"."?".$s."?".">".$s.$h;});

It's a variation of this quine:

ob_start(function($b){ return "<"."?\n$b?".">\n$b"; });?>
ob_start(function($b){ return "<"."?\n$b?".">\n$b"; });

but it also adds "helloworld" to the output and replaces 0 with 0+1 (in the next iteration 1 with 1+1 and so on). Using substr any existing "helloworld" output gets removed before the new "helloworld" gets added.

To get different output, one letter of "helloworld" gets capitalized (determined by the incrementing number). This is the relevant code:

$h=hello.world;$h[0]=$h[0]^' '

A challenge was to not use any numbers except here and for the number replacement


There you already see that +1 is realized as +(int)true.

For the substring arguments I needed 0, 146:

!i, ord(I)+ord(I)

The non-empty string "i" gets coerced to true and negated. false is a valid integer argument and is treated like 0. ord(I) is the ASCII value of "I": 73

Output (1st iteration):

<?ob_start(function($s){$s=substr(str_replace(1,1+(int)true,$s),!i,ord(I)+ord(I));$h=hello.world;$h[1]=$h[1]^' ';return "<"."?".$s."?".">".$s.$h;});?>ob_start(function($s){$s=substr(str_replace(1,1+(int)true,$s),!i,ord(I)+ord(I));$h=hello.world;$h[1]=$h[1]^' ';return "<"."?".$s."?".">".$s.$h;});Helloworld

Output (2nd iteration):

<?ob_start(function($s){$s=substr(str_replace(2,2+(int)true,$s),!i,ord(I)+ord(I));$h=hello.world;$h[2]=$h[2]^' ';return "<"."?".$s."?".">".$s.$h;});?>ob_start(function($s){$s=substr(str_replace(2,2+(int)true,$s),!i,ord(I)+ord(I));$h=hello.world;$h[2]=$h[2]^' ';return "<"."?".$s."?".">".$s.$h;});hElloworld

Output (10th iteration):

This is the last valid output but not a valid program anymore

<?ob_start(function($s){$s=substr(str_replace(10,10+(int)true,$s),!i,ord(I)+ord(I));$h=hello.world;$h[10]=$h[10]^' ';return "<"."?".$s."?".">".$s.$h?>ob_start(function($s){$s=substr(str_replace(10,10+(int)true,$s),!i,ord(I)+ord(I));$h=hello.world;$h[10]=$h[10]^' ';return "<"."?".$s."?".">".$s.$hhelloworlD

Scroll far to the right to find the "Hello world" strings!

  • \$\begingroup\$ just realized that I can change (int)true to ``!!i` and save 12 bytes. Will try to golf it a bit more later \$\endgroup\$ Commented Nov 5, 2015 at 15:35

Pip, 48 - 50% = 24

V Y"`V Y`.RPyRh:ST`helloworld`UCh@<0.h@>0R0o+0"

which evolves as follows:

V Y"`V Y`.RPyRh:ST`helloworld`UCh@<1.h@>1R1o+1"
V Y"`V Y`.RPyRh:ST`Helloworld`UCh@<2.h@>2R2o+2"
V Y"`V Y`.RPyRh:ST`HElloworld`UCh@<3.h@>3R3o+3"
V Y"`V Y`.RPyRh:ST`HELloworld`UCh@<4.h@>4R4o+4"
V Y"`V Y`.RPyRh:ST`HELLoworld`UCh@<5.h@>5R5o+5"
V Y"`V Y`.RPyRh:ST`HELLOworld`UCh@<6.h@>6R6o+6"
V Y"`V Y`.RPyRh:ST`HELLOWorld`UCh@<7.h@>7R7o+7"
V Y"`V Y`.RPyRh:ST`HELLOWOrld`UCh@<8.h@>8R8o+8"
V Y"`V Y`.RPyRh:ST`HELLOWORld`UCh@<9.h@>9R9o+9"
V Y"`V Y`.RPyRh:ST`HELLOWORLd`UCh@<10.h@>10R10o+10"
V Y"`V Y`.RPyRh:ST`HELLOWORLD`UCh@<11.h@>11R11o+11"
V Y"`V Y`.RPyRh:ST`HELLOWORLD`UCh@<12.h@>12R12o+12"

with the last output being invalid because the HELLOWORLD hasn't changed. (Correct me if I haven't done the bonus right.)

Thanks to this question, I just discovered a new quine technique! The base quine is V Y"`V Y`.RPy":

  Y"         "  Yank that string into the variable y
V               Evaluate it as a Pip expression:
          RPy   y wrapped in double quotes (repr)
    `V Y`.      Prepend that regex pattern
                When this is evaluated, it returns a pattern object, which is
                auto-printed--conveniently, without the `` delimiters

Our extra code modifies the string in y, before repr-ing it, as follows:

  • Replace the current helloworld with one in which the leftmost 0 characters are uppercased;
  • Replace all occurrences of 0 with o+0 (where o is a builtin variable that equals 1).

The next time around the number in the code is 1 instead of 0, and so forth.


Javascript, 52 bytes

function(){return '("hello world").replace(" ","")'}



<='("hello world").replace(" ","")'

=> eval('("hello world").replace(" ","")')

<= 'helloworld'


BBC BASIC, 56 bytes

I had a crack at this before I realized how late to the game I am. For what it's worth, here's my version and my first attempt at StackExchange code golf.

Here, V. echoes out the characters given by the ASCII codes in the following comma separated list and P. is shorthand for print. I make use of the backspace character to overwrite the existing 'helloworld' string.

Input code:


First Output:


Second Output:


It can be tested online at https://bbc.godbolt.org/

  • \$\begingroup\$ I have definitely never used BBC BASIC, but how can this be tested? If I paste this into the linked emulator, the last line seems to output "Mistake" for me. \$\endgroup\$ Commented Dec 12, 2019 at 14:43
  • \$\begingroup\$ I'll edit my answer for clarity. It's just the first line that need pasting in. The second, generated line can be copied and executed in the emulator by using the PCs cursor and 'end' keys. The third line is allowed to be invalid according to the rules. \$\endgroup\$ Commented Dec 12, 2019 at 14:53

///, 23 bytes

/,//\/ \/\/hello, world

Try it online!

First output:

/ //hello world

Second output:


Keg, 32 28 23 22 21 bytes


Try it online!

This prints:


Which prints:


05AB1E, score 15 9

-9 bytes thanks to ovs.

’"Ÿ™ ‚ï"á

Try it online!


"hello world"á

Second output:


’...  # trimmed program
’...  # push "\"hello world\"á"
      # implicit output

"..."á  # trimmed program
     á  # push only letters in...
"..."   # literal
        # implicit output
  • 1
    \$\begingroup\$ 9 bytes using string compression \$\endgroup\$
    – ovs
    Commented Jan 18, 2021 at 21:25
  • \$\begingroup\$ Thanks, I would've if I didn't realize that the string hello world didn't need to be in the original program... lol \$\endgroup\$
    – Makonede
    Commented Jan 18, 2021 at 23:10

Vyxal D, 20.5 bytes


Try it Online!

This outputs all 1024 different capitalisations of helloworld.

`                     q‛:Ė+           `:Ė # Quine structure
                           ,              # Eventually print the result
                            helloworld    # Ignored
 ⌐÷                                       # Push the bits before and after the comma
   :a                                     # Check capitalisation
     Bk⁋+›bḢ                              # Binary increment
            ¨£ßN∑                         # Capitalise
                 kTtp                     # Prepend a comma
                     +                    # Append to the rest of the code

Your Answer

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