A good resolution for 2015 is to live more sustainably. We'll start by recycling. Recycling code, that is!

Your task is to print the number 2015 to STDOUT, with or without trailing newline (and only that). However, you have to do so by recycling some old code from PPCG. Here is how that works:

  • Pick any answer posted on CodeGolf.SE before 2014-12-16 00:00:00Z (the day I posted this in the sandbox). Exception: You may not use any answers from last year's New Year's challenge.
  • Choose one code block from that answer (not an inline code snippet, it has to be a on its own paragraph). This block must be advertised as actual code, e.g. you cannot use test cases or example output which happen to use monospace formatting.
  • Rearrange the characters in that code block to form your submission for this challenge. You may only change the order, not add or remove any characters. This includes newlines.
  • You must be able to show that the original source block is syntactically valid in your language. In the best case you can do this by showing that it runs without compile-time or run-time errors. So while the original code may have been Java, you could use it for a Whitespace answer (as every file is valid in Whitespace), but probably can't use it for a Python answer (as the original won't be valid Python syntax).

Note that your answer must ignore all input and external state (including the actual current date). It may read from STDIN, say, as long as it doesn't crash if it's empty, and produces the same output for all possible contents of the stream.

Your resulting code has to be a full program (not a function, nor a snippet which assumes a REPL environment).

This is code golf, so the shortest answer (in bytes) wins.


I'm sure this will play out very differently in different languages. So the following Stack Snippet generates both a regular leaderboard and an overview of winners by language.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:true,success:function(e){answers.push.apply(answers,e.items);if(e.has_more)getAnswers();else process()}})}function shouldHaveHeading(e){var t=false;var n=e.body_markdown.split("\n");try{t|=/^#/.test(e.body_markdown);t|=["-","="].indexOf(n[1][0])>-1;t&=LANGUAGE_REG.test(e.body_markdown)}catch(r){}return t}function shouldHaveScore(e){var t=false;try{t|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(n){}return t}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading);answers.sort(function(e,t){var n=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0],r=+(t.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0];return n-r});var e={};var t=1;answers.forEach(function(n){var r=n.body_markdown.split("\n")[0];var i=$("#answer-template").html();var s=r.match(NUMBER_REG)[0];var o=(r.match(SIZE_REG)||[0])[0];var u=r.match(LANGUAGE_REG)[1];var a=getAuthorName(n);i=i.replace("{{PLACE}}",t++ +".").replace("{{NAME}}",a).replace("{{LANGUAGE}}",u).replace("{{SIZE}}",o).replace("{{LINK}}",n.share_link);i=$(i);$("#answers").append(i);e[u]=e[u]||{lang:u,user:a,size:o,link:n.share_link}});var n=[];for(var r in e)if(e.hasOwnProperty(r))n.push(e[r]);n.sort(function(e,t){if(e.lang>t.lang)return 1;if(e.lang<t.lang)return-1;return 0});for(var i=0;i<n.length;++i){var s=$("#language-template").html();var r=n[i];s=s.replace("{{LANGUAGE}}",r.lang).replace("{{NAME}}",r.user).replace("{{SIZE}}",r.size).replace("{{LINK}}",r.link);s=$(s);$("#languages").append(s)}}var QUESTION_ID=43048;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:&lt;(?:s&gt;[^&]*&lt;\/s&gt;|[^&]+&gt;)[^\d&]*)*$)/;var NUMBER_REG=/\d+/;var LANGUAGE_REG=/^#*\s*([^,]+)/
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script><link rel=stylesheet type=text/css href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><div id=answer-list><h2>Leaderboard</h2><table class=answer-list><thead><tr><td></td><td>Author<td>Language<td>Size<tbody id=answers></table></div><div id=language-list><h2>Winners by Language</h2><table class=language-list><thead><tr><td>Language<td>User<td>Score<tbody id=languages></table></div><table style=display:none><tbody id=answer-template><tr><td>{{PLACE}}</td><td>{{NAME}}<td>{{LANGUAGE}}<td>{{SIZE}}<td><a href={{LINK}}>Link</a></table><table style=display:none><tbody id=language-template><tr><td>{{LANGUAGE}}<td>{{NAME}}<td>{{SIZE}}<td><a href={{LINK}}>Link</a></table>

  • \$\begingroup\$ Not every Whitespace program is valid; I got an error for ideone.com/Jphkf3 \$\endgroup\$
    – Ypnypn
    Commented Jan 1, 2015 at 2:56
  • \$\begingroup\$ This question just came to my mind: is it allowed to recycle the original code in a way that you comment out a huge part of the original? \$\endgroup\$
    – ProgramFOX
    Commented Jan 1, 2015 at 12:31
  • \$\begingroup\$ @ProgramFOX yes, because if you have to comment out a lot that will probably hurt your score. \$\endgroup\$ Commented Jan 1, 2015 at 12:37
  • \$\begingroup\$ @Ypnypn That looks like a runtime error to me though, not a syntax error, right? \$\endgroup\$ Commented Jan 1, 2015 at 13:08

14 Answers 14


GolfScript, 9 bytes

The original answer (dibs!) is also in GolfScript, which is how I know it is syntactically valid. I tested on http://golfscript.apphb.com/ .


I despise the use of languages designed for golfing, but I had to win this challenge, so I betrayed my values by posting this answer. I don't know what most of the characters do in this language, but I once inadvertently learned, while skimming a GolfScript answer, that an unmatched } comments out the rest of the program. This allowed me to ignore the rest of the characters.

  • 1
    \$\begingroup\$ Huh, I'd never thought unmatched braces would be valid in GS. \$\endgroup\$ Commented Jan 1, 2015 at 0:47
  • 3
    \$\begingroup\$ @MartinBüttner Did you never see this? \$\endgroup\$ Commented Jan 1, 2015 at 1:03

Befunge-93, 2085 bytes

I thought I'd have fun and go meta by recycling the best of the recycled. Not going for any awards for brevity here.

+2012+1+1e1 or b+bbv+b+NN
p((('?'.ord-' '.ord )/(1.0/'A'.ord)).to_i)
                   _"  fabaaaca"-.-.-.-.+"O"2::++p

eEe ddd OoOOoOOoOOoOOoOOoOOoOOoOOoOOoO ddD Ccc eEE
ccc LLl
SssSss LLl

+   +     a     pppp  pppp  y   y     n   n eeeee +     +    y   y eeeee     a     rrr    "
+   +    a a    p   p p   p  y y      nn  n e      + + +      y y  e        a a    r  r   "
+++++   aaaaa   pppp  pppp    y       n n n eee    + + +       y   eee     aaaaa   rrr    "
+   +  a     a  p     p       y       n  nn e       + +        y   e      a     a  r  r
+   + a       a p     p       y       n   n eeeee   + +        y   eeeee a       a r  r   "

Hope to see another round of awesome programming puzzles and code golf challenges

"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " ' ' ' ' '

Big char dump below (will clean up if there's more languages to squeeze in):


print(int(ord('A')/(one/(ord(' ')-one))))

This is actually also a polyglot for 5 languages: Befunge-93, oOo Code, Pyth, Python 3 and Ruby. However, since the original code is only syntactically valid for Befunge-93, I'm only counting that.

Unfortunately the original code had only one pair of [] and too many .s, so I wasn't able to actually fit Brainfuck in (hence the oOo Code).


This turned out to be surprisingly restrictive, because:

  • The full set of digits available is 001111111222, requiring the use of ord for Ruby and Python. In particular there's no 5, which turned out to be a pain for Pyth.
  • The lack of @ meant that p needed to be used to place an @ for Befunge.
  • The lack of * meant that we had to multiply by dividing by the inverse of a number. Fun.


The Befunge program is

                   _"  fabaaaca"-.-.-.-.+"O"2::++p

where we've skipped the useless instructions. We encode each digit as the difference in ASCII values between chars, specifically cabf vs. a.

oOo Code

The corresponding BF is


, of which the only relevant part is



Pyth only executes the first line, so

+2012+1+1e1 or b+bbv+b+NN

Note that Pyth uses an prefix notation, so the first part of the line is actually

2012 + (1 + (1 + (1 % 10)))

(Note: e means %10)

Due to the nature of Pyth, this is automatically printed. The rest of the line is valid Pyth, but the preceeding space before the o suppresses the automatic printing.

Python 3

The majority of the Python code is commented out using strings, especially a large triple-quoted string in the middle. Ignoring a few stray strings, we have:

+2012+1+1e1 or b+bbv+b+NN
print(int(ord('A')/(one/(ord(' ')-one))))

The first and last lines are syntactically valid, but do nothing. The middle two lines print what we need.


The Ruby code is similar, but we're using a heredoc instead of a triple quoted string to comment out most of the program. Ignoring some stray strings, we have:

+2012+1+1e1 or b+bbv+b+NN
p((('?'.ord-' '.ord )/(1.0/'A'.ord)).to_i)

Once again, the first line is syntactically valid, but does nothing. The second line prints what we need.

  • 4
    \$\begingroup\$ Heh, you definitely don't get the "shortest code" award, but +1 for creativity! \$\endgroup\$
    – Doorknob
    Commented Jan 1, 2015 at 18:26

CJam, 12 bytes


The Unscramble the Code topic is a really good source for random number printing. This one was quite fun to piece together :)

T~     bitwise not of 0 is -1                     [-1]
mp     replace with 0 as -1 is not prime          [0]
[]!    not of an empty array (falsy) is 1         [0, 1]
_      copy that 1                                [0, 1, 1]
1+     add 1                                      [0, 1, 2]
o      output top of stack                        [0, 1]           2
E      push 14                                    [0, 1, 14]       2
^      bitwise xor                                [0, 15]          2
       (CJam implicitly prints stack afterwards)  []               2015

Bonus answers

14 bytes:

36.e8 .79e2%15

19 bytes:


Ostrich, 198

I'm excited to get an Ostrich answer out; I don't care how long it is. :P (this is version 0.5.0, by the way)

{: rotate ( circ n -- )
    neg swap change-circular-start

IN: 1 9 [a,b] <circular> dup 6 rotate >array .
{ 4 5 6 7 8 9 1 2 3 }
IN: 1 9 [a,b] <circular> dup 3 rotate >array .
 7 8 9   3 4  6 };2 n15


: rotate ( circ n -- )
    neg swap change-circular-start ;

IN: 1 9 [a,b] <circular> dup 6 rotate >array .
{ 4 5 6 7 8 9 1 2 3 }
IN: 1 9 [a,b] <circular> dup 3 rotate >array .
{ 7 8 9 1 2 3 4 5 6 }

All I changed was the following:

  • Wrapped everything other than 2 n15 in a block ({}) that is immediately popped (;).

  • Stuck 2 n15 at the end. 2 pushes a 2, n pushes a 0, and 15 pushes 15, which ultimately becomes 2015 when output.

This actually helped me find a bug: 2n15 doesn't work for some reason (it prints 215), but both 2 n15 and 2n 15 work. I'll have to figure out why that is....

Here's the search query I used to find this perfect code sample:

created:..2014-12-16 is:answer code:"2" code:"0" code:"1" code:"5" code:"]" code:";"

This answer would work for 140, but I'm going to see if I can go smaller....


JavaScript, 26 bytes





It just shifts 4030 one bit to the right.


CJam, 14 bytes

This one is a bit tricky, so I had to post it even though its a bit long. Original answer is also in CJam, so its valid.

Original answer:

92e8.17 5e6.3%

Recycled 2015:

9.68e3 .7e2%15

How it works

9.68e3 is 9680
.7e2 is 70
9680 70% is 9680%70 = 20
15 is 15

So the stack contains 20 and 15 which are printed one after another, printing 2015

Try it online here


Marbelous, 54 bytes

Boring answer (54 bytes)


(followed by a ton of trailing newlines to equal 54 bytes)

Original Answer

The main board simply drops marbles representing each of character of 2015. R and Q boards are defined, but never used.

Alternative answer (92 bytes)

                @1  @0
03  02
\\  //

Original Answer

Spaces as blank cells should be checked. This first prints 2 (0x32), then prints 0x03+0x02+0x0A=0x0F=15 as a three digit decimal (015). The first three lines do nothing.

Test answers here.


Pyth, 25



Here is the original answer (also written in pyth). I know that this is not a very competitive answer (there is python answer of length 26), but I really enjoyed coming up with this, and I think it comes out into a rather humourous answer.


J6                           : J=6
  i                   ^TT    : convert_to_base(..., 10 BILLION)
   fqT          U*2^TJ       : filter(lambda T: T==..., range(2*10^6)
      ++2010/JJ4             : 2010 + J/J + 4

Basically this is filtering a list of the first two million numbers for being equal to 2015. Then, it treats this list of numbers as the digits of a base 10 BILLION number. Thankfully, there is only one number equal to 2015 in the range, so you get 2015*10000000000^0, which is just 2015. This takes a couple seconds to run.


Perl, 48 bytes

\d>\fDg;print ord($:)*($_=$=+/~?/)+$_|//<<(\n>n)

Original Answer


Python 2, 26 bytes

iiiceex=";;+=*";print 2015

Taken from the Smallest python script to print even numbers 0 to 100 thread. This is probably the solution @FryAmTheEggman was alluding to.


Mathematica, 60 bytes



The part in the Floor brackets is just a series of function applications of non-existing functions (which Mathematica doesn't have a problem with, because of its symbolic computation model). Likewise, just writing the flooring and Print@2015 is multiplication, which Mathematica also doesn't complain about. Without the syntactic sugar, it would be

Floor[ggggiiimmnnoorrrstt[ee[RS[DF[IM], ad], ee], 0.22346]] * Print[2015]

Since we're not assuming a REPL environment, the evaluated result of this is never printed (which would be Null Floor[ggggiiimmnnoorrrstt[ee[RS[DF[IM], ad], ee], 0.22346]]), but only the side effect of the Print actually goes to STDOUT.

Thanks to Sp3000 for turning up the source to this.


><>, 57 bytes

Original C++ code, from the RadioASCII challenge:

#include <cstdio>
int main(){int x;printf("Lawrencium");}

Recycled ><> (Fish) code:


Like Befunge, ><> is a stack-based 2D language. Execution starts from the top left and is initially rightward. Only the first line of the program is executed, in the following manner:

e      Push 14                          [14]
c      Push 12                          [14, 12]
l      Push the length of the stack     [14, 12, 2]
n      Output as num                    [14, 12]          2
e      Push 14                          [14, 12, 14]      2
)      Push 1 if greater than else 0    [14, 0]           2
n      Output as num                    [14]              20
f      Push 15                          [14, 15]          20
n      Output as num                    [14]              2015
;      Terminate                        [14]              2015

Now the big question is — why is the C++ code valid ><>? In ><> there are ways to change the direction of program flow (it's a 2D language, after all):

^>v<     Arrows which direct program flow a certain direction
_/|\     Mirrors which reflect the direction of program flow
#        Four-way mirror, reflect from all directions

When the C++ code is executed, the initial # reflects program flow leftward. But ><> is toroidal, so the instruction pointer wraps around, appearing from the end of the line, meeting the > which directs program flow rightward again. The pointer then wraps back to the #, bounces back to the >... and thus an infinite loop occurs and an error is never thrown.


Python 3, 1878 bytes

Very long, but wanted to share anyway:

import sys,re,zlib as z,base64
print(2015)#,PIL.Image as ire.search(str(z.adler3(i.open(sys.argv[1]).tobytes()[2::6])%203)+'(\\D+',z.decompress(base64.b8decode(b'c${Tc%XZ>86NyfdNqBH<%b?iLI_EpFkwO-GfQC$tcfjoB$+h*^;0s?o$g*?uzgjxs%~BKif!C3zALZEU!&?wJd#-mqgS@p<P&+)AsV|c*52*C>U&(_4w^urvvWJU8Bj;bvv4ia;eiJLu+bsXLru`DjH|W<`|;xLq++kv5k8VWZgQe*`_u+opEF8>A6qjM%k#skzbiuJ7dL_*><K@9l6!M*H(|w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aUv#tkpSyk759Khmvq-aiyM-_&x_VCTx$Vy<;$<k{T$-@{Mhc<<%KD1AHK^MKkg%pYIW}SxhV?&a{o9=rs@*+hqyoioE=TF>9S<KxY+^69^OA0jkS#0!w@kw4}KTcP9#+PVW+qB|7B`Y?eRs+7}8RSAs?i?-Cz#Wp(Iihd`nI!Q_i%R^o_;fvDQ5|{Cr;yWeirL>_l#(wn)$QenJkK6Sgw)5NleBzvo&G#@>X`7Ib*aS4LHx9epI%BXXV&y7LJ&54g}D25-Q8>DZQ5hGKyIeJkQQu08%j|<x~)q(AOVw9P~Z*c0Z@VM6n#<}tBT6+T%4mZ9f*y76xlEFM~o$xr9*SZHd^6D-C!pkkp3m(-~W3&>KY@106L+;I><MJ^Dz`f{(I3i?u`2pWjUjlwZx`B1JB#h#u3xTH*b1K?TG40|4lxF1$_Pw+t?h2')).decode()).group(1))

Taken from KennyTM's answer.

I saw that 2, 0, 1 and 5 and # could be found in the code, so I moved some chars to make print(2015) and could comment out the rest. I also put the PIL import into the comment so it doesn't require that library.


PHP, 21 bytes


Let's try this again. Taken from another PHP answer from Unscramble the Source Code. It's pretty basic, but so far it's the shortest program in a non-golfing language. You can verify it at http://codepad.org/15EjIYAU. The original code is as follows:

  • \$\begingroup\$ You don't even need the 4*2/8 ;) \$\endgroup\$ Commented Jan 3, 2015 at 1:13
  • \$\begingroup\$ I know, but I wanted to make it more interesting, and it would have been commented out anyways. \$\endgroup\$ Commented Jan 3, 2015 at 1:13

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.