# Produce the number 2014 without any numbers in your source code

Note to challenge writers as per meta consensus: This question was well-received when it was posted, but challenges like this, asking answerers to Do X without using Y are likely to be poorly received. Try using the sandbox to get feedback on if you want to post a similar challenge.

It's 2017 2018 2019 2020 2021 already, folks, go home.

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.

Leaderboard:

var QUESTION_ID=17005,OVERRIDE_USER=7110;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
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><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• Even though numbers are ignored in brainfuck, I thought I'd post one anyway. 32 Chars: ++++++[>++++++++<-]>++.--.+.+++. – Braden Best Apr 1 '15 at 21:37
• Brainfuck isn't a valid language for this challenge. – Joe Z. Apr 1 '15 at 22:49
• I know. That's why I posted it as a comment – Braden Best Apr 1 '15 at 22:51
• I wonder if this question gets a small spike in popularity around New Year's. – Joe Z. Dec 26 '15 at 23:28
• Waiting for "Come on folks, don't you realize it's 2016?" :) – padawan Jan 4 '16 at 23:35

# Mouse-2002, 4 bytes.

That's 4 bytes of pure, sweet ASCII.

In Mouse, the letters of the alphabet are initialised to the values 0-25. ! is the operator for printing integers, thus this prints 20 then 14 (no intermittent newline).

U!O!


There's no online interpreter available, but here you will find an interpreter written in C (needing some tweaks before one can coerce gcc to compile it) and the same compiled interpreter for Win32 but which works perfectly on Linux with wine.

Here you can find the fixed version of the interpreter, which compiles.

• Wow, this is an amazing find so much later after the challenge. And with a language so esoteric nobody here had heard of it yet! – Joe Z. Dec 9 '15 at 1:19
• BTW: this does the same thing as CJam's KE, but is actually valid because it's a language from before 2014. – Joe Z. Dec 9 '15 at 1:30
• The smug look on my face right now resembles that of a Fortran-77 wizard after beating some proponent of Python in a fastest-code. – cat Dec 9 '15 at 1:33
• This a game of @cat and Mouse-2002. – Digital Trauma Oct 7 '16 at 5:00
• @DigitalTrauma indeed :3 – cat Oct 7 '16 at 6:44

# Python, 52 bytes

print sum(ord(c) for c in 'Happy new year to you!')


Updated for 2015 thanks to @Frg:

print sum(ord(c) for c in 'A Happy New Year to You!')


Mouse over to see 2016 version:

print sum(ord(c) for c in 'Happy New Year to you!!!')

Try it online!

• You deserve the cleverness award – Carter Pape Jan 1 '14 at 19:49
• wow - this is so in the spirit of this question. <3 – Johannes Jan 1 '14 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 '14 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 '14 at 15:31
• sum(map(ord,'Happy new year to you!')) would save 7 characters. – user2186 Jan 2 '14 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
Happy.new.year


But it's so unenthusiastic. I prefer:

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

Happy.new.year!


Or even:

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

Have.a.happy.new.year!


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
end

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!

• Happy = Time; Happy.new.year – John Dvorak Jan 1 '14 at 8:18

# Befunge 98 - 17119 8 bytes

'-:*b-.@


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 $$(a,b)∈[32,126]\times[10,15]\land a^2-b=2014$$ 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:
print("%s,%s"%(a,c))


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

cdd**e-.@


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:

"*'&("#;:aj@a+,;


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

• en.wikipedia.org/wiki/Befunge ...what is this i don't even... – Plato Jan 2 '14 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 '14 at 15:21
• @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 '14 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 – Justin Jan 3 '14 at 9:06
• Wiki: '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' ...but why? – CousinCocaine Jan 28 '14 at 20:17

# Go, 2 bytes (UTF-16)

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

—


http://ideone.com/dRgKfk

can't load package: package :
prog.go:1:1: illegal character U+2014 '—'

• That's very clever, but the question requests a program that prints the number. – HelloGoodbye Jan 4 '14 at 15:18
• If printed error codes count, this submission should win. – ToastyMallows Jan 5 '14 at 15:51
• +1. The question doesn't say, "prints only the number and nothing else". – Kaz Jan 14 '14 at 22:31
• I don't care if its valid or not, it's pretty awesome. – Redwolf Programs May 5 '19 at 2:01
• This is a standard loophole – MilkyWay90 Aug 3 '19 at 4:56

# Python 2, 26 bytes

print int('bbc',ord("\r"))


Try it online!

• bbc is 2014 in base 13 – Darren Stone Jan 1 '14 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 '14 at 15:34
• 13 years ago. RIP. – Darren Stone Jan 2 '14 at 18:30
• IMO, this answer is in "True Pythonese" – kmonsoor Jan 4 '14 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 '14 at 4:25

## MATLAB, Scala (4 characters, 5 bytes)

You can take advantage of MATLAB's (and Scala's) relatively weak type system, here. The trick is to apply the unary + operation on a string composed only of the character ߞ (of UTF-8 code point U+07DE, or 2014 in decimal). This operation implicitly converts the string to a double (in MATLAB) and to an Int (in Scala):

+'ߞ'


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)

\def~{\the\catcode}~}~\\~\%\bye


An even shorter alternative (proposed by Joseph Wright) is

\number^^T\number^^N\bye


## XeTeX/LuaTeX (13 characters, 14 bytes)

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

\numberߞ\bye

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

# dc, 6 chars

DiBBCp

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

Console output:

$dc <<< "DiBBCp" 2014  • True, but the actual dc program is still DiBBCp (6 chars), the rest is just a way to run it. – daniero Jan 3 '14 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 '14 at 19:01 • @PabloMarin-Garcia, unfortunatelly some unaware person broke it... Has 43 votes now. Please go back and downvote! :) – Tomas Jan 14 '14 at 16:07 • @Tomas Vogons always the Vogons. Resistance is futile against the intergalactic burocracy. – Pablo Marin-Garcia Jan 15 '14 at 0:03 • I cannot even find the D command in the man page. What does it do? Never mind... D is hex for 13. – kzh Apr 28 '14 at 18:40 ## 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: x<-(T+T);x+floor(exp(pi)^x)*x*x-(x*x)^(x*x)/x  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: m=Math;p=m.pow;t=true;++t+m.floor(p(m.exp(m.PI),t))*t*t++-p(++t,t--)/--t  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): P.S. If you can make the same algorithm shorter in a different language, post a comment with it. • o=!"";(o+o)+""+(o-o)+(o+o-o)+(o+o+o+o) – Kernel James Jan 2 '14 at 10:32 • 25 bytes: alert('ߞ'.charCodeAt()) – oberhamsi Jan 2 '14 at 14:13 • +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. – Justin Jan 4 '14 at 9:19 • This wasn't the first answer to not use character codes; I have several earlier ones. – Timtech Jan 4 '14 at 12:39 • @Quincunx: you're right; skimming through I didn't catch that your version was using hex digits, not character codes. – AmeliaBR Jan 4 '14 at 15:47 ### 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: '@'*' '-'"'  or "{yz}"map(_-'I'toChar)  which have 11 and 22 chars respectively. • 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. – Konrad Borowski Jan 1 '14 at 19:32 • I added a golfed version. – Mikaël Mayer Jan 1 '14 at 20:12 • You could save a couple characters from the toInt like this: +"Happy new year to you!".sum Test – theon Jan 2 '14 at 21:26 • Updated. I did not know that + could also be a prefix. – Mikaël Mayer Jan 3 '14 at 9:49 ## C, 33 bytes main(){printf("%d",'A'*' '-'B');}  • How annoying that the prime factorization of 2014 requires ASCII 5! – Ben Jackson Jan 1 '14 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 '14 at 17:21 • main(){printf("%d",'\a\xde');} – mjy Jan 5 '14 at 15:07 • @mjy Byte order of multi-character literals is not guaranteed. – Jonathon Reinhart Jan 5 '14 at 22:14 • @JonathonReinhart multi-character literals are entirely implementation-defind. – FUZxxl Apr 8 '15 at 12:14 # PHP, 9 bytes This requires PHP 7.1 or lower. It will work in PHP 7.2, but it will result in a warning. No guarantees for any future version. 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 2014  Alternatively, save this using ISO-8859-1 encoding. <?=~ÍÏÎË;  • @Quincunx: Uploading this was relatively tricky, but here is Ideone - ideone.com/APHKhn. – Konrad Borowski Jan 1 '14 at 10:47 • This looks interesting; what does it do? – Justin Jan 1 '14 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. – Konrad Borowski Jan 1 '14 at 10:50 • Since the question was "Now that it is 2014...", how about echo date('Y');? – John Jan 2 '14 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. – Konrad Borowski Jan 3 '14 at 12:39 ### 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. >>>  • This won't work once people update their version of Python 3 a year from now. – Joe Z. Jan 11 '14 at 22:51 • That's why I mentioned python3.4.0b2, It wont happen twice. Its release date, not system date. – YOU Jan 12 '14 at 3:18 • This made me smile! – Matt Fletcher Aug 2 '14 at 11:24 • Also works in Python 3.4.2. – Erik the Outgolfer Sep 14 '16 at 17:56 • You are not allowed to add extraneous output. – MilkyWay90 Jul 5 '19 at 4:31 ## Mathematica, 14 characters (or 15 if you count the bitmap as a character) TextRecognize@ • Actually, you should count bytes so it's 14 + the size of the bitmap image. – Sylwester Jan 1 '14 at 18:46 • The bitmap would probably be 7,357 characters, really. – Joe Z. Jan 1 '14 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. – John Dvorak Jan 1 '14 at 18:49 • You are all killjoys. Fine, use First@ToCharacterCode@"ߞ" for 25 characters, 26 bytes. – Michael Stern Jan 1 '14 at 18:59 • As a bonus, here's a Mathematica solution in 30 characters --URLFetch@"goo.gl/miVwHe" – Michael Stern Jan 1 '14 at 19:42 # Javascript, 23 bytes Uses Base 64 Conversion alert(atob("MjAxNA=="))  23 chars (16 with atob by itself) Or alert("MMXIV") // ;)  • MMXIV has no characters in common with 2014, last I checked... // ;) – Joe Z. Jan 1 '14 at 6:45 • The ancient Romans might disagree. The first one produces 2014 though, in modern English. – logic8 Jan 1 '14 at 6:48 • Your first one doesn't output though... – Doorknob Jan 1 '14 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 '14 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. – Nope Jan 3 '14 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. say~"ÍÏÎË"  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
73:61:79:7e:22:cd:cf:ce:cb:22
$perl -M5.010 ~/tmp/ten-stroke.pl 2014  Perl (without high bits) - 14 characters say''^RPQT  This uses a bitwise "or" on the two four-character strings "RPQT" and "" (that is, four backticks). $ ~/tmp/fourteen-stroke.pl
73:61:79:27:60:60:60:60:27:5e:52:50:51:54
$perl -M5.010 ~/tmp/fourteen-stroke.pl 2014  (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: say${$|}  For consistency, let's do the hexcat-then-perl thing with that: $ hexcat 2014
73:61:79:24:7b:24:7c:7d
$perl -M5.010 2014 2014  I think this is cheating, but it's an interesting solution nonetheless, so worth mentioning. • 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 '14 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 '14 at 12:04 • @DomHastings, personally I think if you're going to do it with "-e" or "-E", I'd say that you should then have to include the entire command, including "perl -E" in your character count. – tobyink Jan 1 '14 at 13:35 • Relevant meta answer – Peter Taylor Jan 1 '14 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 '14 at 17:56 ## Ruby, 20 p 'bbc'.to_i ?\r.ord  Explanation: bbc is 2014 in base 13. Shorter than Python. Not as short as Forth. • "Nobody writes jokes in base 13!" – Jean-Michaël Celerier Jan 1 '14 at 12:21 • w=?$;"^XA[_AXeMFGIAHJLjKNAEFEJJNHQHNKLAEMINJOJOHLAGKHOJOJ[AG[HQHRFJAH}IHAIGGwIIAHHGwKHAHGHrEUAGQFiGVAGQGfIPAFHKHHbJHAQII]MGASHNSOHATIdIAUJJRLIAWLIQGKAZOFUA]ZAeSAiPAjOAkLA".codepoints{|r|r-=68;$><<(r<0??\n:(w=w==?$?' ':?$)*r)} – Darren Stone Jan 1 '14 at 17:49 • p 'ߞ'.ord for a fully functional program, 'ߞ'.ord inside irb. Works on 1.9+ – Ricardo Panaggio Jan 3 '14 at 2:37 • Without "strange" unicode characters: ?-*?--?\v (45 * 45 - 11) (Ruby 1.8) – Ricardo Panaggio Jan 3 '14 at 2:45 • One character smaller: ?.*?.-?f (46 * 46 - 102) (Ruby 1.8 only again) – Ricardo Panaggio Jan 3 '14 at 2:58 ## 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. • According to codegolf.stackexchange.com/tags/code-golf/info, it should count as 9 characters. – Konrad Borowski Jan 1 '14 at 11:15 • @GlitchMr, thanks, I've corrected my answer. – Danko Durbić Jan 1 '14 at 11:22 • The [''] is a nice trick. I usually used [char] but that's indeed shorter :) – Joey Jan 8 '14 at 8:57 ### 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. ## Javascript, 18 characters alert(btoa('ÛMx')) Update: in ES6, using a template literal can save two characters: alert(btoaÛMx) 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. • the question mentions printing the number. I know that evaluation in a console will lead to the result being returned, but on Code Golf it's generally expected that JS answers will include some form of IO (alert is most common). – zzzzBov Jan 3 '14 at 16:22 • @zzzzBov Yes, my original answer included an alert call. – GOTO 0 Jan 3 '14 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 '14 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/…). – Konrad Borowski Jan 4 '14 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 '14 at 18:12 ### 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. ;-) ## C (31) main(){printf("%o",' b'/'\b');}  ## C (32) main(){printf("%x%o",' ','\f');}  ## C (30) main(){printf("%x",' j'^'~');}  ## C (30) main(){printf("%d",'\a\xde');}  • 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 '14 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 '14 at 16:14 • Bah, checked with integer division that 8212/'b' == 'S' :( – MSalters Jan 2 '14 at 16:37 • and octal doesn't work either (02014=1036=37*28, 28 is unprintable) – MSalters Jan 2 '14 at 16:44 • @FredOverflow what about my 28 char solution? main(){puts(__DATE__+'\a');} – Arunprasad Rajkumar Jan 8 '14 at 5:18 ## Forth, 14 '> '" * '^ - .  • Can you explain how this works? – ProgramFOX Jan 1 '14 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 '14 at 11:14 • Forth (Gforth 0.7.0), 5 bytes, 4 chars: 'ߞ . It prints the character. – 18446744073709551615 Jan 9 '14 at 11:03 # GolfScript, 14 '-+,/'{)))))}%  How it works: ASCII goes like this: ... + , - . / 0 1 2 3 4 ...  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). • The + at the end is unnecessary. Also, rather than increment 5 times, just add five. Total savings: 4 chars. '-+,/'{5+}% – Justin Jan 1 '14 at 10:42 • @Quincunx, 5 is a number. – Peter Taylor Jan 1 '14 at 10:48 • @PeterTaylor I keep forgetting. – Justin Jan 1 '14 at 16:43 • Clever solution – Sumurai8 Jan 2 '14 at 7:38 • The CJam version of this: "-+,/"_,)f+. :) (Then again, CJam has KD.) – Martin Ender Dec 18 '14 at 18:38 ## 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'ߞ')
2014


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)

• ord(',')**2+ord('N') – MLS Jan 7 '14 at 16:42
• @MLS Well, that has a digit in it :) – Joachim Isaksson Jan 7 '14 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 – Ponkadoodle Jan 8 '14 at 2:19
• You can save a character if you use Python 3: ord('ߞ') – asmeurer Jan 11 '14 at 20:24
• @JoachimIsaksson A digit is no number ;) – univalence Aug 26 '16 at 18:50

# 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.

• 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. – Justin Jan 1 '14 at 9:59
• Also, with your version, a=ord('.');print(a*a-ord('f')) is 2 chars shorter. – Justin Jan 1 '14 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 '14 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 '14 at 15:41
• Similar as commented above, without unicode print ord('.')**2-ord('f') is slightly shorter. – MLS Jan 7 '14 at 16:45

## APL (6 bytes, 4 chars)

⊃⎕TS


Only works this year though.

Why it works:

      ⎕TS
2014 1 1 11 58 5 811
⊃⎕TS
2014


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

⎕UCS'ߞ'

• Unfortunately, answers that only work for this year are invalid. – Joe Z. Jan 1 '14 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 '14 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 '14 at 17:12
• @CarlWitthoft: It's called a quad (⎕), it's supposed to look like that. – marinus Jan 1 '14 at 17:12

## R (20 character)

@popojan (he is not allowed to post an answer here yet) has provided the solution within 20 characters.

sum(T+T:exp(T+pi))-T


Output:

> sum(T+T:exp(T+pi))-T
[1] 2014


## R (22 character)

Anonymous user has suggested shorter solution.

strtoi("bbc",pi*pi+pi)


2014 is BBC in base 13. pi*pi+pi (=13.0112) is treated by R in this context as the integer 13. Output:

> strtoi("bbc",pi*pi+pi)
2014


## R (30 character)

Thanks to @Tomas!

cat(a<-T+T,T-T,T/T,a*a,sep="")


Output:

> cat(a<-T+T,T-T,T/T,a*a,sep="")
2014


## R (31 character)

cat(T+T,T-T,T/T,T+T+T+T,sep="")


Inspired from the answer by AmeliaBR. Output:

> cat(T+T,T-T,T/T,T+T+T+T,sep="")
2014

• Wow, +1! And I hoped my roman numerals solution will be the best... :( ;-) – Tomas Jan 14 '14 at 15:35
• The variants below can be made shorter: cat(a<-T+T,T-T,T/T,a^a,sep="") (30 chars), paste0(aT+T,T-T,T/T,a^a) (26 chars) – Tomas Jan 15 '14 at 10:16
• @Tomas, the function paste0 is not allowed, as it contains the symbol 0. Your solution makes 30 characters if using cat. – djhurio Jan 21 '14 at 10:47
• create file 2014 in current directory and write list.files() - 12 characters – Zbynek Jan 31 '14 at 17:00
• @Zbynek, I expect your solution not to be valid in the general scope of codegolf rules. – djhurio Feb 1 '14 at 9:19

## Java - 77 75 characters

75 characters if print is added in a class with the main method:

class C{public static void main(String[]a){System.out.print('#'*'<'-'V');}}


It means 35*60-86 which is equal to 2014

• I like your formula. – Johannes Jan 1 '14 at 23:30
• This actually needs to be longer, because the class definition needs to be in it to run. Shortest way I know (with Java 6):class a{static{System.out.println('#'*'<'-'V');}} – Justin Jan 2 '14 at 0:29
• @Quincunx, with Java 7, a main method is needed – True Soft Jan 2 '14 at 20:53
• @TrueSoft Note I said "with Java 6". You should choose the shortest Java possible. – Justin Jan 3 '14 at 0:43
• You can remove 'ln' in println to reduce chars... – laksys Jan 3 '14 at 10:22

# CJam - 2

KE


K and E` are variables preset to 20 and 14.
I created CJam in 2014 so it's ok if it doesn't qualify.