22
2
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.
1Do the usual quine rules apply or is the program is allowed to read its own source file? – Martin Ender – 2015-11-05T10:36:23.683
1Usual quine rules do apply. – None – 2015-11-05T10:38:38.200
Does the original code count towards the bonuses? Likewise, does the original code have to contain a valid
hello world
? – Martin Ender – 2015-11-05T15:13:57.0501Original code counts towards bonuses. Original code does not have to contain a valid hello world. – None – 2015-11-05T16:10:31.333
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 – 2015-11-05T16:22:58.643
You are right. I will remove the "it may contain multiple valid hello world strings", as that does not break any of the existing answers. – None – 2015-11-05T16:33:24.963
$a=qq( )^helloworld;print map"\$a=qq(\0 )^$a;$_,q($_)",q(print map"\$a=qq(\0\0 )^$a;$_,q($_)")
(94 bytes) should (I think) work in Perl 5, but isn't working on my machine (the \0 prints as a space for some reason). Maybe someone can fix it up and post it as an answer. It's based on Tushar Samant's quine. – msh210 – 2015-11-05T17:39:19.407Does the program ever need to produce an invalid answer, or can it keep going? – anOKsquirrel – 2015-11-05T18:53:01.140
@anOKsquirrel There are 3072 valid answers. After you are done with those, your next output is invalid. – None – 2015-11-05T18:58:31.773
@Ville-ValtteriTiittanen What if I slightly change the source code? Can I do that? – anOKsquirrel – 2015-11-05T19:10:25.897
@anOKsquirrel Source code can change as much as you want between each execution. However, as soon as you output a hello world string that has been output during some earlier execution, your program has failed. "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." – None – 2015-11-05T19:18:22.873
@Ville-ValtteriTiittanen Oh, didn't see that thanks – anOKsquirrel – 2015-11-05T19:52:21.817