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
helloworld

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

Hello, world
hellO WORld
HELLoworlD

These strings are not valid:

Hello     world
Hello(newline)world
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.

Example

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
    Do the usual quine rules apply or is the program is allowed to read its own source file? – Martin Ender Nov 5 '15 at 10:36
  • 1
    Usual quine rules do apply. – user46926 Nov 5 '15 at 10:38
  • Does the original code count towards the bonuses? Likewise, does the original code have to contain a valid hello world? – Martin Ender Nov 5 '15 at 15:13
  • 1
    Original code counts towards bonuses. Original code does not have to contain a valid hello world. – user46926 Nov 5 '15 at 16:10
  • 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) – Fabian Schmengler Nov 5 '15 at 16:22

12 Answers 12

up vote 7 down vote accepted

Pyth, 17 bytes

A different Pyth solution:

"r\"helloworld\"1

Output:

r"helloworld"1

Second output:

HELLOWORLD
  • 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. – user46926 Nov 6 '15 at 11:38
  • 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. – user46926 Nov 6 '15 at 11:39
  • At the time of answering, the rules were "Your program is not valid for this contest unless at least two first executions are successful" – Fabian Schmengler Nov 6 '15 at 11:41
  • 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. – user46926 Nov 6 '15 at 11:49

Mathematica, 214 - 50% = 107 bytes

(a = Characters[StringJoin["helloworl", "d"]]; b = Apply[StringJoin, Tuples[Transpose[{a, ToUpperCase[a]}]], {1}]; StringReplacePart[ToString[#0, InputForm], b[[FirstPosition[b, "helloworld"] + 1]], {180, 189}]) & 

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
    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.) – Martin Ender Nov 5 '15 at 13:54

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

Heh! Beat that! You probably will. :c

First output:

'0DV\{25^-V\}}1+{rd3*Z;helloworld
'                                 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:

'1DV\{25^-V\}}1+{rd3*Z;helloworlD

Third output:

'2DV\{25^-V\}}1+{rd3*Z;helloworLD

Fourth output:

'3DV\{25^-V\}}1+{rd3*Z;hellowoRLD

Fifth output:

'4DV\{25^-V\}}1+{rd3*Z;hellowORLD

Sixth output:

'5DV\{25^-V\}}1+{rd3*Z;helloWORLD

Seventh output:

'6DV\{25^-V\}}1+{rd3*Z;hellOWORLD

Eighth output:

'7DV\{25^-V\}}1+{rd3*Z;helLOWORLD

Ninth output:

'8DV\{25^-V\}}1+{rd3*Z;heLLOWORLD

Tenth output:

'9DV\{25^-V\}}1+{rd3*Z;hELLOWORLD

Eleventh output:

':DV\{25^-V\}}1+{rd3*Z;HELLOWORLD

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

  • 1
    o_o Simplex struggled down to 21. I'll work on beating 18.15, though! – Conor O'Brien Nov 5 '15 at 18:54
  • @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. – Addison Crump Nov 5 '15 at 19:09
  • I thought simplex would be awesome, since it has an outer program function, but noooo that would count as one program. le sigh – Conor O'Brien Nov 5 '15 at 19:14
  • +1 for beating (or almost beating) the "classic" golfing languages – ev3commander Nov 5 '15 at 22:48
  • @ev3commander I would've beaten them if the iteration bonus was higher. :c – Addison Crump Nov 6 '15 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<}_~
{`_E=-"_~HelloWorld"2<}_~
{`_E=-"_~Helloorld"2<}_~

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

Test it here.

Explanation

{`     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.

  • Does this qualify for the -10% bonus? The outputs only contain two of the three valid punctuation forms. – Mike Bufardeci Nov 5 '15 at 14:38
  • @MikeBufardeci Oh good question... I sort of assumed the original code was part of it. – Martin Ender Nov 5 '15 at 15:13
  • 1
    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%. – user46926 Nov 5 '15 at 16:13

CJam 69 60 - 50% = 30

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

{`_40>\40<_38>~)`2Te[\25<"helloworld"00YbATe[.{{el}{eu}?}`+]W%"_~"}_~

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.

Explanation

{`_40>\40<_38>~)`2Te[\25<"helloworld"00YbATe[.{{el}{eu}?}`+]W%"_~"}_~
{`                                                                      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.

{`_6<\"helloworld"01YbW%.{{eu}{el}?}`\I>_2<~)`2Te[\2>"_~"}_~
{`                                                   "_~"}_~ 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
  • You have a different language and a shorter answer, so there's nothing wrong using same approach as the Mathematica answer. – user46926 Nov 5 '15 at 13:35
  • Note that we are looking for the lowest score, not the fastest poster or the most novel algorithm. – user46926 Nov 5 '15 at 13:40
  • @Ville-ValtteriTiittanen Still, Martin Büttner's answer is still lower than me – Akangka Nov 5 '15 at 13:42
  • @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). – Martin Ender Nov 5 '15 at 13:53

GolfScript, 35 bytes − 50% = 17.5

0"HelloWorld"{@@{^.32&\}%`@".~"}.~

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:

0"HelloWorld"{@@{^.32&\}%`@".~"}.~
0"HeLlOWoRlD"{@@{^.32&\}%`@".~"}.~
0"HelLOWorLD"{@@{^.32&\}%`@".~"}.~
0"HeLLOWoRLD"{@@{^.32&\}%`@".~"}.~
0"HellowORLD"{@@{^.32&\}%`@".~"}.~
32"HeLlOworld"{@@{^.32&\}%`@".~"}.~
0"hELloWoRlD"{@@{^.32&\}%`@".~"}.~
32"helLowORld"{@@{^.32&\}%`@".~"}.~
0"HeLLoWORlD"{@@{^.32&\}%`@".~"}.~
32"HellOWORld"{@@{^.32&\}%`@".~"}.~
0"hElLOWORlD"{@@{^.32&\}%`@".~"}.~
32"heLLOWORld"{@@{^.32&\}%`@".~"}.~
32"HelloworLd"{@@{^.32&\}%`@".~"}.~
32"hElLoWoRLd"{@@{^.32&\}%`@".~"}.~
0"HEllOWorlD"{@@{^.32&\}%`@".~"}.~

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. ;-)

Pyth, 18 bytes

"-\"hello world\"d

Which returns:

-"hello world"d

Which in turn prints:

helloworld

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

  • 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. – DLosc Nov 6 '15 at 23:33

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? ._.

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

2nd Output:

"f[helloworld]-:D-``"§R'Hg
"                   "      ~~ 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[Helloworld]-:D-``
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:

HelloworlD

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

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

Output:

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

Final output:

helloworld

Attempt 1, v.0.7+ 28 26 bytes

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

"BhelloworldB"t[s32S;]'gs;
"            "             ~~ 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:

"HELLOWORLD"g

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

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

Final output:

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

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.

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

str_replace(0,0+(int)true,$s)

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!

  • just realized that I can change (int)true to ``!!i` and save 12 bytes. Will try to golf it a bit more later – Fabian Schmengler Nov 5 '15 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(" ","")'}

Test

=>

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

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

<= 'helloworld'

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.