Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

So, now that it's 2014, it's time for a code question involving the number 2014.

Your task is to make a program that prints the number 2014, without using any of the characters 0123456789 in your code, and independently of any external variables such as the date or time or a random seed.

The shortest code (counting in bytes) to do so in any language in which numbers are valid tokens wins.

By popular request, here is a scoreboard.

By language (Unicode unless specified otherwise):

By language, ASCII only (may be same as above):

Invalid but interesting answers:

  • AutoHotkey: 13 bytes (prints the current year)
  • C: 2 bytes (part of an error message)
  • Go: 3 bytes (part of an error message)
  • Morse Code: 23 bytes (the "numbers" that are valid tokens aren't really numbers)
  • Python Interpreter 3.4.0b2: 0 bytes (part of interpreter default output)
  • Ruby: 15 bytes (prints the current year)

The scoreboard may be incomplete or inaccurate (especially the ASCII-only part) as I'm not confident in my abilities to comb through 90+ answers manually; please correct any errors you spot.

share|improve this question
And by "valid tokens" I mean tokens that actually represent numbers. Numerical characters being comments does not mean they are "valid". –  Joe Z. Jan 1 at 5:04
No, it has to be 2014 exactly. –  Joe Z. Jan 1 at 5:49
I am a bit confused. Why do you like to accept answers so early? –  Quincunx Jan 1 at 9:54
Do we count characters or bytes? A lot of languages can take advantage of multibyte characters here, and since all the programs are rather small, this makes a lot of difference. –  daniero Jan 1 at 14:14
@Quincunx: I change the accepted answer from time to time to update which one is the shortest. –  Joe Z. Jan 1 at 15:33

135 Answers 135

up vote 181 down vote accepted

Befunge 98 - 17 11 9 8 bytes


Similar to the old version, but I remembered about '

'-:* pushes 45, duplicates it, then squares it, producing 2025
b-   subtracts 11 from it, resulting in 2014
.@   prints the result, then ends the program

Interestingly, 452-11 is the only pairing of numbers a,b where


The significance of those sets is that [32,126] is the set of printable ascii characters and [10,15] is the set of easily accessible Befunge numbers. I found that pair with this python program:

for a in range(32,127):
    for c in range(10,16):
        if (a**2-c)==2014:

Or, if your interpreter supports unicode, then this works:

Befunge 98 - 5 bytes (4 chars)


It at least works on http://www.quirkster.com/iano/js/befunge.html with the following code (Befunge 93 - 6 bytes / 5 chars):


Old version


computes the number, then prints it:

cdd pushes numbers to the stack so that it is this: 12,13,13
**  multiplies top three values of stack, which is now: 2028
e   pushes 14
-   subtracts the top two values of the stack, resulting in: 2014
.   prints the numerical value
@   end of program

Older version:


Pushes the ascii values for 2014, -10. Then prints each after adding 10 to it.

share|improve this answer
en.wikipedia.org/wiki/Befunge ...what is this i don't even... –  Plato Jan 2 at 13:16
"The language was originally created by Chris Pressey in 1993 as an attempt to devise a language which is as hard to compile as possible"... –  will Jan 2 at 15:21
Wouldn't a:+.e.@ achieve the same? Saves a character by printing 20 and then 14. –  MSalters Jan 2 at 15:38
@11684 The output is rather well defined in the question. If a program printed: randomstuff2randomstuff0randomstuff1randomstuff4 I wouldn't consider it a valid solution. –  Cruncher Jan 2 at 17:45
@Plato Rather than read the wikipedia article (which only includes Befunge 93), if you want to learn about Befunge 98, read the official specs –  Quincunx Jan 3 at 9:06

Python (52 bytes)

print sum(ord(c) for c in 'Happy new year to you!')
share|improve this answer
You deserve the cleverness award –  Carter Pape Jan 1 at 19:49
wow - this is so in the spirit of this question. <3 –  Johannes Jan 1 at 19:51
I was a little surprised that it was only the 4th phrase I tried after "Happy new year!", which would have been perfect for the year 1374. –  dansalmo Jan 1 at 20:14
print sum(ord(c) for c in 'HAPPY NEW YEAR To you too.') Oh wait, I'm a year late. That's 2013. –  Warren P Jan 2 at 15:31
sum(map(ord,'Happy new year to you!')) would save 7 characters. –  Gareth Rees Jan 2 at 16:19

Ruby, 15

p Time.new.year

Temporary ;)

Note that the section of the question

independently of any external variables such as the date or time or a random seed

was not edited in until long after I posted my answer...

Jan Dvorak offers a great alternative in the comments:

Happy = Time

But it's so unenthusiastic. I prefer:

Happy = Time
class Time; alias year! year; end


Or even:

class Have; def self.a; A.new; end; end
class A; def happy; Time; end; end
class Time; alias year! year; end


And here's correct English punctuation:

def noop x = nil; end
alias a noop
alias happy noop
alias new noop
alias year! noop
def Have x
    p Time.new.year

Have a happy new year!

Okay okay, I couldn't help it:

def noop x = nil; end
eval %w[we wish you a merry christmas! christmas and a happy new].map{|x|"alias #{x} noop"}*"\n"
def year!; p Time.new.year; end

we wish you a merry christmas! we wish you a merry christmas!
we wish you a merry christmas and a happy new year!
share|improve this answer
Happy = Time; Happy.new.year –  Jan Dvorak Jan 1 at 8:18
@hobbs No it's not; the question says nothing about this –  Doorknob Jan 1 at 16:14
This will only work correctly some of the time. –  hippietrail Jan 1 at 16:58
It has worked well in all tests to date –  CoderTao Jan 1 at 17:38
I believe the spirit of the question was to say the current year [which happens to be 2014 this year]. This solution is therefore more "portable" in time than the accepted one ;). You (and Jan Dvorak) get my vote! –  Olivier Dulac Jan 2 at 12:03

Matlab (4 characters, 5 bytes)

The trick is to cast a string composed only of the character ߞ (of UTF-8 code point U+07DE, which corresponds to 2014 in decimal) to an integer, using the + operator:


Byte-count details:

  • + is ASCII and counts for 1 byte
  • ' is ASCII and counts for 1 byte (but appears twice in the expression)
  • ߞ is a 2-byte UTF-8 character

Total: 5 bytes

TeX (32 26 characters, as many bytes)


An even shorter alternative (proposed by Joseph Wright) is


XeTeX/LuaTeX (13 characters, 14 bytes)

If XeTeX or LuaTeX are allowed, UTF-8 input can be used directly (as proposed by Joseph Wright):

share|improve this answer
\let~\number~`^^T~`^^N\bye 25 chars/bytes. You IMHO count wrong, it's 25 for your solution as well. –  tohecz Jan 2 at 19:46
@tohecz I think both our solutions are actually 26-byte long. –  Jubobs Jan 2 at 19:55
If the current year is wanted, then 13 bytes: \the\year\bye –  tohecz Jan 2 at 20:03
@tohecz Assuming your system clock is correct :) –  Jubobs Jan 2 at 20:08
+'ߞ' also works in Scala (and a few other languages I imagine) –  theon Jan 2 at 21:22

Python, 198 120 49

/\ /\ | | |
 / || | |_|
/_ \/ |   |''')
share|improve this answer
The quesitons says, "Produce the '''number''' 2014") –  dimension10 Jan 2 at 11:18
@dimension10 Easy to fix: render that into TIFF, OCR into a string and parse as base 10 number. –  Rafał Dowgird Jan 2 at 13:56
I was wondering when somebody would do the ASCII-art solution. –  Joe Z. Jan 2 at 14:57
I like this one, I don't care if it isn't a number. made me smile a little –  Malachi Jan 2 at 20:41
@dimension10: This is the number 2014, just not in the form you expected! :) –  HelloGoodbye Jan 4 at 14:41

Python, 26

print int('bbc',ord("\r"))
share|improve this answer
bbc is 2014 in base 13 –  Darren Stone Jan 1 at 10:50
I assume the use of the characters 'bbc' and the use of base 13 is a Douglas Adams tribute. "I may be a sorry case, but I don't write jokes in base 13." –  Brian Minton Jan 2 at 15:34
13 years ago. RIP. –  Darren Stone Jan 2 at 18:30
IMO, this answer is in "True Pythonese" –  kmonsoor Jan 4 at 15:11
@BrianMinton: The use of Base 13 is probably because it's the only base between 2 and 36 that allows the number 2014 to be represented without any of the characters 0-9. –  dan04 Jan 5 at 4:25

Go - One unicode character (2 bytes in UTF-16, 3 bytes in UTF-8 format), output 2014 as part of an error


can't load package: package : 
prog.go:1:1: illegal character U+2014 '—'
share|improve this answer
That's very clever, but the question requests a program that prints the number. –  HelloGoodbye Jan 4 at 15:18
If printed error codes count, this submission should win. –  ToastyMallows Jan 5 at 15:51
+1, brilliant. This should be the accepted answer. –  Jeff Gohlke Jan 6 at 19:37
+1. The question doesn't say, "prints only the number and nothing else". –  Kaz Jan 14 at 22:31

Visual C/C++ (2 bytes)

... as long as you don't mind the required output being embedded in a compiler error!


Live demo, producing:

testvc.cpp(1) : error C2014: preprocessor command must start as first nonwhite space
share|improve this answer
I don't get it. They seem to be in the right order to me. –  Colin Watson Jan 4 at 13:28
Sorry, C2014 is clearly a hexadecimal value equal to 794,644 in base 10. ;) –  David Conrad Jan 7 at 23:41
It's not a hexadecimal value, it's the category of the error. In this case a Compiler error (for example, "CA" would indicate a Code Analysis error, etc...) –  BrainSlugs83 Jan 13 at 4:22
Now this is the most hilarious answer given here :) –  tohecz Jan 24 at 10:45

dc, 6 chars


D pushes 13 on the stack, even tho the input radix is 10 initially. i changes input radix (to 13) and BBC is 2014 base 13. p prints.

Console output:

$ dc <<< "DiBBCp"
share|improve this answer
dc<<<DiBBCp - a bit shorter –  mpapis Jan 3 at 17:32
True, but the actual dc program is still DiBBCp (6 chars), the rest is just a way to run it. –  daniero Jan 3 at 17:51
I was going to upvote this but it has 42 points! uses base 13 and the word BBC. How cool is that! Seems that this year we will find the question for life, universe and everithing ;-) en.wikipedia.org/wiki/Base_13. I am upvoting @daniero's comment instead and leave the answer with this magnificent 42 reputation ;-) –  Pablo Marin-Garcia Jan 12 at 19:01
@PabloMarin-Garcia, unfortunatelly some unaware person broke it... Has 43 votes now. Please go back and downvote! :) –  Tomas Jan 14 at 16:07
@Tomas Vogons always the Vogons. Resistance is futile against the intergalactic burocracy. –  Pablo Marin-Garcia Jan 15 at 0:03

72 45 characters in the code; Zero character codes

This is far from the shortest answer posted, but no one has yet posted an answer that

  • doesn't use character codes as a substitute for numbers, and
  • doesn't call the system date.

Using pure math (okay, and an automatic boolean conversion) in R, from the R console:


Prints out the number 2014. T is a pre-defined synonym for true in R. The floor and exp functions are directly available in the base package, as is the pi constant. R doesn't have an increment operator, but repeating the (x*x) turned out to be fewer characters that doing increment and decrement twice each.

Original version in Javascript (72 characters)

For the simple reason that I could test out in the console, and it doesn't mind a complete lack of whitespace:


run in your console and it will print back the number 2014.

Props to xkcd (and also) for getting me to think about exp(pi): e to the pi Minus pi

P.S. If you can make the same algorithm shorter in a different language, post a comment with it.

share|improve this answer
+1 for the "purity of purpose" of your solution. –  Joe Z. Jan 1 at 18:27
o=!"";(o+o)+""+(o-o)+(o+o-o)+(o+o+o+o) –  Kernel James Jan 2 at 10:32
25 bytes: alert('ߞ'.charCodeAt()) –  oberhamsi Jan 2 at 14:13
From anonymous user: Shorter Javascript version (68 characters): m=Math;p=m.pow;t=true;++t+m.floor(p(m.exp(m.PI),t))*t*t-p(t*t,t*t)/t Even shorter Javascript version (64 characters): m=Math;p=m.pow;t=!!t;++t+(p(m.exp(m.PI),t)|t-t)*t*t-p(t*t,t*t)/t –  David Carraher Jan 3 at 21:45
+1. However, you claim your answer was the first answer that "doesn't use character codes as a substitute for numbers, and doesn't call the system date". That is actually false. My answer has this solution cdd**e-.@ (posted before yours) which does not make use of character codes or system date. It computes the number 2014. c,d, and e are hexadecimal number digits. a,b,...,f push (respectively) 10,11,...15 so 12 * 13 * 13 - 14 is the computation. –  Quincunx Jan 4 at 9:19

Scala REPL

34 29 characters.

+"Happy new year to you!".sum

Well ok if you really want it golfed with any chars, you can use:

'@'*' '-'"'



which have 11 and 22 chars respectively.

share|improve this answer
Interesting idea, even if it's not particularly golfed. But the string itself makes it more interesting, than something using high bytes, or something like that. –  xfix Jan 1 at 19:32
I added a golfed version. –  Mikaël Mayer Jan 1 at 20:12
You could save a couple characters from the toInt like this: +"Happy new year to you!".sum Test –  theon Jan 2 at 21:26
Updated. I did not know that + could also be a prefix. –  Mikaël Mayer Jan 3 at 9:49


main(){printf("%d",'A'*' '-'B');}

33 characters

share|improve this answer
How annoying that the prime factorization of 2014 requires ASCII 5! –  Ben Jackson Jan 1 at 8:56
I got for(int a;YES;a++){NSLog(@"%i",a);} for Cocoa Touch objective C but I can't add yet (not rated enough). It does show a 2014 eventually and it has a compiler error and is possible it may not work at all and compiled is probably about 4.2 meg - but hey. –  Recycled Steel Jan 3 at 17:21
main(){printf("%d",'\a\xde');} –  mjy Jan 5 at 15:07
@mjy Byte order of multi-character literals is not guaranteed. –  Jonathon Reinhart Jan 5 at 22:14

Morse Code, 23


..--- ----- .---- ....-
share|improve this answer
"in any language in which numbers are valid tokens" –  Doorknob Jan 1 at 22:50
"..---" is a valid token, in 5 strokes, for the number two, right? Just as "4" is a valid token, in three strokes, for the number "four". –  David Carraher Jan 1 at 23:04
Good point. Btw, I was relieved that no one asked how I get Morse Code to run on my computer. –  David Carraher Jan 3 at 5:14
@DavidCarraher What do you mean? I naturally assumed you used this repo to decode it. github.com/Nyubis/mspa-morse-decoder Everyone's doing it... –  Michael Calkins Jan 4 at 20:28
@MichaelCalkins Of course. How silly of me. –  David Carraher Jan 4 at 20:32

PHP (9 bytes)

xxd needed because of binary data (so copying and pasting it would be easier). May return E_NOTICE, but it doesn't really matter, does it?

~ $ xxd -r > 2014.php
0000000: 3c3f 3d7e cdcf cecb 3b                   <?=~....;
~ $ php 2014.php
share|improve this answer
@Quincunx: Uploading this was relatively tricky, but here is Ideone - ideone.com/APHKhn. –  xfix Jan 1 at 10:47
This looks interesting; what does it do? –  Quincunx Jan 1 at 10:48
@Quincunx: It does bitwise not (0x00 changes into 0xFF, and 0x7F changes into 0x80) on every character of the string. As the string is valid identifier (anything with high bit set is an identifier character for PHP, probably to support other encodings), PHP thinks it's a constant, but because it's not defined, it treats it as a string. –  xfix Jan 1 at 10:50
Since the question was "Now that it is 2014...", how about echo date('Y');? –  John Jan 2 at 19:05
@John: Nope. If you would read the comments for the question, you would notice that OP doesn't want the to get current year as an answer. Besides, <?=date(Y); would be 11 characters, and I have solution in 9 characters. –  xfix Jan 3 at 12:39

Ruby, 20

p 'bbc'.to_i ?\r.ord

Explanation: bbc is 2014 in base 13. Shorter than Python. Not as short as Forth.

share|improve this answer
"Nobody writes jokes in base 13!" –  Jean-Michaël Celerier Jan 1 at 12:21
+1 just for base 13! –  Thorbjørn Ravn Andersen Jan 1 at 20:53
p 'ߞ'.ord for a fully functional program, 'ߞ'.ord inside irb. Works on 1.9+ –  Ricardo Panaggio Jan 3 at 2:37
Without "strange" unicode characters: ?-*?--?\v (45 * 45 - 11) (Ruby 1.8) –  Ricardo Panaggio Jan 3 at 2:45

Javascript / Base 64 Conversion


23 chars (16 with atob by itself)


alert("MMXIV") // ;)
share|improve this answer
MMXIV has no characters in common with 2014, last I checked... // ;) –  Joe Z. Jan 1 at 6:45
The ancient Romans might disagree. The first one produces 2014 though, in modern English. –  logic8 Jan 1 at 6:48
Your first one doesn't output though... –  Doorknob Jan 1 at 16:14
if you open the console in chrome, paste it and hit enter it returns the value - I'll add an alert to it as its longer than others anyway. –  logic8 Jan 1 at 17:54
@logic8: Nice one +1. Another JavaScript version which also works: (4 bytes) [!+[]+!+[]]+[+[]]+[+!+[]]+[!+[]+!+[]+!+[]+!+[]] - alert([!+[]+!+[]]+[+[]]+[+!+[]]+[!+[]+!+[]+!+[]+!+[]]); Though I'm not sure it meets Joe Z's requirements. –  François Wahl Jan 3 at 15:03

Perl - 10 characters

This solution is courtesy of BrowserUK on PerlMonks, though I've shaved off some unnecessary punctuation and whitespace from the solution he posted. It's a bitwise "not" on a four character binary string.


The characters displayed above represent the binary octets cd:cf:ce:cb, and are how they appear in ISO-8859-1 and ISO-8859-15.

Here's the entire script in hex, plus an example running it:

$ hexcat ~/tmp/ten-stroke.pl
$ perl -M5.010 ~/tmp/ten-stroke.pl

Perl (without high bits) - 14 characters


This uses a bitwise "or" on the two four-character strings "RPQT" and "````" (that is, four backticks).

$ ~/tmp/fourteen-stroke.pl
$ perl -M5.010 ~/tmp/fourteen-stroke.pl

(I initially had the two strings the other way around, which required whitespace between print and RPQT to separate the tokens. @DomHastings pointed out that by switching them around I could save a character.)

Perl (cheating) - 8 characters

This is probably not within the spirit of the competition, but hdb on PerlMonks has pointed out that Perl provides a variable called $0 that contains the name of the current program being executed. If we're allowed to name the file containing the script "2014", then $0 will be equal to 2014. $0 contains a digit, so we can't use it directly, but ${...} containing an expression that evaluates to 0 will be OK; for example:


For consistency, let's do the hexcat-then-perl thing with that:

$ hexcat 2014
$ perl -M5.010 2014

I think this is cheating, but it's an interesting solution nonetheless, so worth mentioning.

share|improve this answer
Hey there, if you reverse the string and barewords, you can save a char: print"````"^RPQT. It might be possible to use say too on 5.10+ using -E instead of -e, but I don't know if that incurs a +2 penalty for different command-line args? –  Dom Hastings Jan 1 at 11:54
It's considered acceptable to specify that you're using Perl 5 and use say for no penalty. –  Peter Taylor Jan 1 at 12:04
Thanks for confirming! –  Dom Hastings Jan 1 at 12:07
Relevant meta answer –  Peter Taylor Jan 1 at 14:24
You may also save another byte by using string literals that don't require quotes, such as say ABCD^srrp. –  primo Jan 9 at 17:56

Mathematica, 14 characters (or 15 if you count the bitmap as a character)

TextRecognize@enter image description here

share|improve this answer
Actually, you should count bytes so it's 14 + the size of the bitmap image. –  Sylwester Jan 1 at 18:46
The bitmap would probably be 7,357 characters, really. –  Joe Z. Jan 1 at 18:46
Also, I believe some of the bytes in the image fall into the \d range. Namely, if it's the GIF, then the header itself is guaranteed to contain some. –  Jan Dvorak Jan 1 at 18:49
You are all killjoys. Fine, use First@ToCharacterCode@"ߞ" for 25 characters, 26 bytes. –  Michael Stern Jan 1 at 18:59
As a bonus, here's a Mathematica solution in 30 characters --URLFetch@"goo.gl/miVwHe"; –  Michael Stern Jan 1 at 19:42

Powershell, 9


ߞ (U+07DE NKO LETTER KA) is counted as two bytes according to the code-golf tag info.

[""] returns the first character from the string ("" is converted to 0). The unary plus opeartor (+) converts the character to an integer.

share|improve this answer
According to codegolf.stackexchange.com/tags/code-golf/info, it should count as 9 characters. –  xfix Jan 1 at 11:15
@GlitchMr, thanks, I've corrected my answer. –  Danko Durbić Jan 1 at 11:22
The [''] is a nice trick. I usually used [char] but that's indeed shorter :) –  Joey Jan 8 at 8:57

Yet another GolfScript entry, 9 printable characters

I believe this is shorter than any of the printable GolfScript entries so far:


(Peter Taylor's 7-char entry beats it, but includes non-printable control characters.)

I call this the "that's so last year!" entry, because what it actually does is generate the number 2013 in 8 chars, as 33 × 61, and then increments it by one. ;-)

share|improve this answer
You win (for ascii golfscript) –  aditsu Jan 1 at 16:39

Scala REPL - 6 chars


(## is Scala's symbol meaning hashCode, and the Java string "?=" hashes to 2014.)

Scala REPL - 4 chars, 5 bytes


Math on our favorite unicode character produces an Int.

share|improve this answer

GolfScript, 14


How it works: ASCII goes like this:


So, this takes the ASCII codes of each character, subtracts five, and sticks it in a string.

{...}% yields an array of the characters of a string mapped, when given a string as an argument. So, it increments each character by 5 () means increment).

share|improve this answer
The + at the end is unnecessary. Also, rather than increment 5 times, just add five. Total savings: 4 chars. '-+,/'{5+}% –  Quincunx Jan 1 at 10:42
@Quincunx, 5 is a number. –  Peter Taylor Jan 1 at 10:48
@Quincunx Thanks, edited –  Doorknob Jan 1 at 13:32
@PeterTaylor I keep forgetting. –  Quincunx Jan 1 at 16:43
Clever solution –  Sumurai8 Jan 2 at 7:38

APL (6 bytes, 4 chars)


Only works this year though.

Why it works:

2014 1 1 11 58 5 811

Without relying on the system date, it's 10 bytes (7 characters):

share|improve this answer
Unfortunately, answers that only work for this year are invalid. –  Joe Z. Jan 1 at 15:34
I don't know APL: is that square box an APL char, or am I missing a font representation (Chrome) ? –  Carl Witthoft Jan 1 at 16:24
@JoeZ.: The question doesn't say that but I've added one that doesn't rely on it being 2014. –  marinus Jan 1 at 17:12
@CarlWitthoft: It's called a quad (), it's supposed to look like that. –  marinus Jan 1 at 17:12

Forth, 14

'> '" * '^ - .      
share|improve this answer
Can you explain how this works? –  ProgramFOX Jan 1 at 11:04
I'm expressing integer constants as character literals using their ordinal (ASCII) values. So this is: 62 34 * 94 - . If you don't speak Forth, this means print (62 * 34 - 94). –  Darren Stone Jan 1 at 11:14
Forth (Gforth 0.7.0), 5 bytes, 4 chars: 'ߞ . It prints the character. –  18446744073709551615 Jan 9 at 11:03

Python 32 10 bytes, 91 85 (66 with math imported by default) bytes pure math

Had some fun writing this:

my_lst = []
for i in range(33, 126):
    for j in range(i, 126):
        if 2014 - 126 < i * j < 2014 - 33:
            if j not in range(48, 58):
                my_lst.append("ord('" + unichr(i) +
                              "')*ord('" + unichr(j) +
                              "')+ord('" + unichr(2014 - i * j) + "')")

for val in my_lst:
    print val, '->', eval(val)

Prints all the possible ways I can write 2014 using Bruno Le Floch's method (32 chars):

ord('!')*ord(':')+ord('d') -> 2014
ord('!')*ord(';')+ord('C') -> 2014
ord('!')*ord('<')+ord('"') -> 2014
ord('"')*ord(':')+ord('*') -> 2014
ord(')')*ord('/')+ord('W') -> 2014
ord('*')*ord('-')+ord('|') -> 2014
ord('*')*ord('.')+ord('R') -> 2014
ord('*')*ord('/')+ord('(') -> 2014
ord('+')*ord(',')+ord('z') -> 2014
ord('+')*ord('-')+ord('O') -> 2014
ord('+')*ord('.')+ord('$') -> 2014
ord(',')*ord(',')+ord('N') -> 2014
ord(',')*ord('-')+ord('"') -> 2014

But this is obviously redundant, so if your interpreter is set to utf-8 by default, then all it takes is:

>>> ord(u'ߞ')

Also, thanks to AmeliaBR (for the idea), I tried my best to implement a pure math version:

from math import*
a,b,c=int(e),round(e),ceil(pi);print int(a**(b*c-(c-b))-a*a**c-a)
share|improve this answer
ord(',')**2+ord('N') –  MLS Jan 7 at 16:42
@MLS Well, that has a digit in it :) –  Joachim Isaksson Jan 7 at 23:00
I optimized your math version a bit: a,b=int(e),int(pi);c=a+a;print a**(b*c-c+b)-a*a**c-a, and you can eliminate the math import altogether by making use of the fact that True in Python 2.x is identical to the integer 1 in operation, bringing it down to 50 characters: o=True;a=o+o;b=a+o;c=b+o;print a**(b*c-o)-a*a**c-a –  Wallacoloo Jan 8 at 2:19
You can save a character if you use Python 3: ord('ߞ') –  asmeurer Jan 11 at 20:24

Python, 32 chars

print ord(',')*ord('-')+ord('"')

Probably possible to reduce it using the 2014 th Unicode char ߞ, but I didn't try.

Quincunx notes that

a=ord('.');print a*a-ord('f')

is shorter by three chars.

share|improve this answer
The unicode version works, at least in Python 3 with IDLE: print(ord("ߞ")). It does not appear to work in Python 2; Python 2 probably does not support unicode. –  Quincunx Jan 1 at 9:59
Also, with your version, a=ord('.');print(a*a-ord('f')) is 2 chars shorter. –  Quincunx Jan 1 at 10:06
@Quincunx It does support, however you need to have a specific encoding set to your file and append u at the end of the string (would be "ߞ"u) –  Kroltan Jan 1 at 16:23
@Kroltan Actually, I'm pretty sure the second part is not true. In Python 2, you had to prepend strings with u to say that they were unicode, but in Python 3, all strings are automatically unicode –  murgatroid99 Jan 2 at 15:41
@murgatroid99 Ah, sorry. It's been a while since I used python, and my brain remembered about C-style float literals (1453f) –  Kroltan Jan 2 at 18:38

C (31)

main(){printf("%o",' b'/'\b');}

C (32)

main(){printf("%x%o",' ','\f');}

C (30)

main(){printf("%x",' j'^'~');}

C (30)

share|improve this answer
How about just "%x" and 'b'*'S' ? That's 8212 dec or 2014 hex. Saves one char one literal and two on format string. –  MSalters Jan 2 at 15:26
@MSalters No, 'b'*'S' is 8134. The prime factorization of 8212 is 2*2*2053, so I don't see an easy way to produce it. –  FredOverflow Jan 2 at 16:14
Bah, checked with integer division that 8212/'b' == 'S' :( –  MSalters Jan 2 at 16:37
and octal doesn't work either (02014=1036=37*28, 28 is unprintable) –  MSalters Jan 2 at 16:44
@FredOverflow what about my 28 char solution? main(){puts(__DATE__+'\a');} –  Arunprasad Rajkumar Jan 8 at 5:18

GolfScript (10 8 7 chars)

This solution contains non-printable characters. As xxd output:

0000000: 2714 0e27 7b7d 2f                        '..'{}/

As base 64:


Unpacks the ASCII codes for characters 20 and 14 and prints those numbers without any separation.

To actually generate the number 2014, I'm currently at 8 chars:

0000000: 2713 6a27 7b2a 7d2a                      '.j'{*}*


Takes a string containing characters with ASCII values 19 and 106 and multiplies them to get 2014.

share|improve this answer
Does it really take 3 characters to output the ascii codes for a string? That's sad :/ –  aditsu Jan 1 at 12:08
Printing 20 and 14 without separation is acceptable. –  Joe Z. Jan 7 at 1:37
I guess this can be actually shortened to 6 chars with {xy}.* where x and y represent 20 and 14 in ASCII. –  Vereos Jan 8 at 17:42
@Vereos, I somehow missed seeing your comment earlier. Very nice, and sufficiently different that it's worth posting as a separate answer. –  Peter Taylor Mar 5 at 14:24
Alright, I will :) –  Vereos Mar 5 at 15:05

Javascript, 18 characters


JSFiddle: http://jsfiddle.net/pBjL2/

Update: the code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.

Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".

Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

share|improve this answer
the question mentions printing the number. I know that evaluation in a console will lead to the result being returned, but on Programming Puzzles & Code Golf it's generally expected that JS answers will include some form of IO (alert is most common). –  zzzzBov Jan 3 at 16:22
@zzzzBov Yes, my original answer included an alert call. –  GOTO 0 Jan 3 at 17:21
It lists Community as having removed the alert. I wonder if the standards have changed for JS codegolf or whether it's just a change that was adopted by Community. –  zzzzBov Jan 3 at 17:28
@zzzzBov: It was a change by anonymous user accepted by SHiNKiROU and luser droog. Anyway, this edit triggered a discussion on Meta (meta.codegolf.stackexchange.com/questions/803/…). –  xfix Jan 4 at 11:19
@xfix, It's not this edit alone that caused me to ask that question on meta, I've seen enough code golfs where people get into disagreements over whether the dev console counts as printing, that I figured it was worth asking for a standard. –  zzzzBov Jan 4 at 18:12

Python3.4.0b2 (0 bytes)

% python3.4  
Python 3.4.0b2 (v3.4.0b2:ba32913eb13e, Jan  5 2014, 11:02:52) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
share|improve this answer
This won't work once people update their version of Python 3 a year from now. –  Joe Z. Jan 11 at 22:51
That's why I mentioned python3.4.0b2, It wont happen twice. Its release date, not system date. –  YOU Jan 12 at 3:18

protected by Community Jan 1 at 22:35

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.