10
Write two code fragments, which we will call s_zero and s_one.
Program (l, n) consists of l copies of s_zero and s_one corresponding with the digits of n in binary, padded with s_zero on the left.
For example, if s_zero = foo
and s_one = bar
then
Program (4, 0) = foofoofoofoo
Program (4, 1) = foofoofoobar
Program (4, 2) = foofoobarfoo
etc.
Program (l, n) must print the source of Program (l, (n + 1) mod (2^l)) to standard out. In the example above, foobarfoofoo
must print foobarfoobar
when executed.
Your score is the sum of the lengths of fragments s_zero and s_one
Near duplicate to http://codegolf.stackexchange.com/questions/35974/code-that-runs-the-game-of-life-on-itself - computation done by quining program with 2 different code blocks.
– feersum – 2015-01-26T03:53:47.550Can the program read its own source code? – Doorknob – 2015-01-26T03:53:50.210
2@feersum I disagree. This one is a lot easier, in particular, you don't need to be able to determine line breaks. Furthermore, I think the task does make a difference, otherwise every generalised quine challenge would be a dupe of the basic quine challenge. – Martin Ender – 2015-01-26T07:29:21.010
The advantage of the simpler task is that it encourages competition to create the shockingly short answers seen so far- I hope that justifies this challenge as different! – QuadmasterXLII – 2015-01-26T14:48:42.907
1Probably worth noting that s_zero and s_one have to be different. Otherwise I have many solutions with 2*n scores. – randomra – 2015-02-15T11:51:44.733