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.

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

share|improve this question
2  
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
5  
No, it has to be 2014 exactly. –  Joe Z. Jan 1 at 5:49
47  
I am a bit confused. Why do you like to accept answers so early? –  Quincunx Jan 1 at 9:54
16  
@JoeZ. the currently accepted answer is not the shortest posted –  Jan Dvorak Jan 1 at 13:27
4  
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
show 36 more comments

87 Answers

up vote 103 down vote accepted

Befunge 98 - 17 11 9 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]X[10,15]^a2-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:

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

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

share|improve this answer
22  
en.wikipedia.org/wiki/Befunge ...what is this i don't even... –  Plato Jan 2 at 13:16
7  
"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
1  
Wouldn't a:+.e.@ achieve the same? Saves a character by printing 20 and then 14. –  MSalters Jan 2 at 15:38
4  
@11684 The output is rather well defined in the question. If a program printed: randomstuff2randomstuff0randomstuff1randomstuff4 I wouldn't consider it a valid solution. –  Cruncher 2 days ago
2  
@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 2 days ago
show 3 more comments

Python (52 bytes)

print sum(ord(c) for c in 'Happy new year to you!')
share|improve this answer
34  
You deserve the cleverness award –  Carter Pape Jan 1 at 19:49
57  
wow - this is so in the spirit of this question. <3 –  Johannes Jan 1 at 19:51
23  
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
18  
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
46  
sum(map(ord,'Happy new year to you!')) would save 7 characters. –  Gareth Rees Jan 2 at 16:19
show 12 more comments

Ruby, 15

p Time.new.year

Temporary ;)

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!
share|improve this answer
74  
Happy = Time; Happy.new.year –  Jan Dvorak Jan 1 at 8:18
2  
@hobbs No it's not; the question says nothing about this –  Doorknob of Snow Jan 1 at 16:14
6  
This will only work correctly some of the time. –  hippietrail Jan 1 at 16:58
64  
It has worked well in all tests to date –  CoderTao Jan 1 at 17:38
4  
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
show 3 more comments

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)

\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
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 2 days ago
 
@tohecz I think both our solutions are actually 26-byte long. –  Jubobs 2 days ago
 
\1 l2 e3 t4 ~5 \6 n7 u8 m9 b10 e11 r12 ~13 14 ^15 ^16 T17 ~18 19 ^20 ^21 N22 \23 b24 y25 e26 –  Jubobs 2 days ago
1  
If the current year is wanted, then 13 bytes: \the\year\bye –  tohecz 2 days ago
 
@tohecz Assuming your system clock is correct :) –  Jubobs 2 days ago
show 2 more comments

Python

newYear = '''
   _ _      _ _      /|     |     | 
  /   \    /   \    / |     |     | 
 |    /   |     |     |     |_ _ _| 
     /    |     |     |           | 
   _/_ _   \_ _/   _ _|_ _        | '''
print(newYear)
share|improve this answer
3  
The quesitons says, "Produce the '''number''' 2014") –  dimension10 Jan 2 at 11:18
46  
@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
5  
I was wondering when somebody would do the ASCII-art solution. –  Joe Z. Jan 2 at 14:57
2  
I like this one, I don't care if it isn't a number. made me smile a little –  Malachi 2 days ago
1  
After reading all the above answers, this is hilarious. –  bobobobo 2 days ago
show 3 more comments

Python, 26

print int('bbc',ord("\r"))
share|improve this answer
 
Can you explain what this does? –  Quincunx Jan 1 at 10:47
18  
bbc is 2014 in base 13 –  Darren Stone Jan 1 at 10:50
14  
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
2  
13 years ago. RIP. –  Darren Stone 2 days ago
1  
IMO, this answer is in "True Pythonese" –  kmonsoor yesterday
show 4 more comments

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.

share|improve this answer
4  
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 2 days ago
 
Updated. I did not know that + could also be a prefix. –  Mikaël Mayer 2 days ago
add comment

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): 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
3  
+1 for the "purity of purpose" of your solution. –  Joe Z. Jan 1 at 18:27
1  
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 yesterday
 
+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 yesterday
show 3 more comments

C

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

33 characters

share|improve this answer
9  
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 yesterday
 
main(){printf("%d",'\a\xde');} –  mjy 1 hour ago
add comment

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
2014
share|improve this answer
 
This looks neat, but I can't tell what is happening. Can you link to a run on ideone or phpfiddle (or something similar)? –  Quincunx Jan 1 at 10:45
1  
This looks interesting; what does it do? –  Quincunx Jan 1 at 10:48
6  
@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
2  
Since the question was "Now that it is 2014...", how about echo date('Y');? –  John 2 days ago
3  
@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 2 days ago
show 1 more comment

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
11  
"Nobody writes jokes in base 13!" –  Jean-Michaël Celerier Jan 1 at 12:21
1  
w=?$;"^XA[_AXeMFGIAHJLjKNAEFEJJNHQHNKLAEMINJOJOHLAGKHOJOJ[AG[HQHRFJAH}IHAIGGwIIA‌​HHGwKHAHGHrEUAGQFiGVAGQGfIPAFHKHHbJHAQII]MGASHNSOHATIdIAUJJRLIAWLIQGKAZOFUA]ZAeSA‌​iPAjOAkLA".codepoints{|r|r-=68;$><<(r<0??\n:(w=w==?$?' ':?$)*r)} –  Darren Stone Jan 1 at 17:49
3  
+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 2 days ago
 
Without "strange" unicode characters: ?-*?--?\v (45 * 45 - 11) (Ruby 1.8) –  Ricardo Panaggio 2 days ago
show 5 more comments

dc, 6 chars

$ dc <<< "DiBBCp"
2014

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.

share|improve this answer
 
dc<<<DiBBCp - a bit shorter –  mpapis yesterday
 
True, but the actual dc program is still DiBBCp (6 chars), the rest is just a way to run it. –  daniero yesterday
add comment

Javascript / Base 64 Conversion

alert(atob("MjAxNA=="))

23 chars (16 with atob by itself)

Or

alert("MMXIV") // ;)
share|improve this answer
7  
MMXIV has no characters in common with 2014, last I checked... // ;) –  Joe Z. Jan 1 at 6:45
9  
The ancient Romans might disagree. The first one produces 2014 though, in modern English. –  logic8 Jan 1 at 6:48
1  
Your first one doesn't output though... –  Doorknob of Snow Jan 1 at 16:14
1  
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
2  
@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 2 days ago
show 3 more comments

Morse Code 23

;)

..--- ----- .---- ....-
share|improve this answer
9  
"in any language in which numbers are valid tokens" –  Doorknob of Snow Jan 1 at 22:50
4  
"..---" 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
1  
@Doorknob — David is right. –  Nicolas Barbulesco 2 days ago
7  
Good point. Btw, I was relieved that no one asked how I get Morse Code to run on my computer. –  David Carraher 2 days ago
2  
@MichaelCalkins Of course. How silly of me. –  David Carraher 20 hours ago
show 3 more comments

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

TextRecognize@enter image description here

share|improve this answer
11  
Actually, you should count bytes so it's 14 + the size of the bitmap image. –  Sylwester Jan 1 at 18:46
9  
The bitmap would probably be 7,357 characters, really. –  Joe Z. Jan 1 at 18:46
1  
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
5  
You are all killjoys. Fine, use First@ToCharacterCode@"ߞ" for 25 characters, 26 bytes. –  Michael Stern Jan 1 at 18:59
5  
As a bonus, here's a Mathematica solution in 30 characters --URLFetch@"goo.gl/miVwHe"; –  Michael Stern Jan 1 at 19:42
show 3 more comments

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

Update: altered to use say instead of print as per @PeterTaylor's comment. Not only does this shave off two further characters, it adds an attractive line break at the end of the output.

Perl - 16 (or even 14) characters

print'````'^RPQT

Using bitwise "or" on the two four-character strings "RPQT" and "````".

You can knock a couple of characters using die instead of print. However, this results in output to STDERR instead of STDOUT, and the output will be suffixed with the line number of the error. So I class that as a cheat.

(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.)

share|improve this answer
1  
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
1  
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
 
@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 at 13:35
1  
Relevant meta answer –  Peter Taylor Jan 1 at 14:24
show 1 more comment

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

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
7  
@Quincunx, 5 is a number. –  Peter Taylor Jan 1 at 10:48
 
@Quincunx Thanks, edited –  Doorknob of Snow Jan 1 at 13:32
2  
@PeterTaylor I keep forgetting. –  Quincunx Jan 1 at 16:43
 
Clever solution –  Sumurai8 Jan 2 at 7:38
add comment

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
1  
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
add comment

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
add comment

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'ߞ'
share|improve this answer
3  
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
1  
@CarlWitthoft: It's called a quad (), it's supposed to look like that. –  marinus Jan 1 at 17:12
add comment

Go - One unicode character (2 chars in utf16, 3 chars in utf8 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 '—'
share|improve this answer
 
That's very clever, but the question requests a program that prints the number. –  HelloGoodbye yesterday
 
If printed error codes count, this submission should win. –  ToastyMallows 51 mins ago
add comment

Python, 32 chars

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

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

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
2  
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
1  
@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 2 days ago
add comment

Forth, 14

'> '" * '^ - .      
share|improve this answer
 
Can you explain how this works? –  ProgramFOX Jan 1 at 11:04
1  
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
add comment

GolfScript (10 8 7 chars)

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

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

As base 64:

JxQOJ3t9Lw==

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'{*}*

JxNqJ3sqfSo=

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
add comment

Haskell, 23 characters, 24 bytes

main=print$fromEnum 'ߞ'

That's U+07DE N'Ko letter KA

share|improve this answer
 
According to codegolf.stackexchange.com/tags/code-golf/info, it has 24 characters. –  xfix Jan 1 at 11:17
1  
Methinks that's 23 characters, @GlitchMr, though it may be 24 bytes. –  TRiG Jan 1 at 18:18
 
@TRiG: Well, yes. The info page says that "If you use Unicode, byte count should use UTF-8." –  xfix Jan 1 at 19:06
add comment

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)
share|improve this answer
add comment

Mathematica, 23 bytes

Tr@ToCharacterCode@"ߞ"

(Using the 2014 unicode char. Credit for Tr goes to alephalpha)

example

Mathematica, 46 bytes (pure math)

a=⌊E⌋;b=⌈E⌉;c=⌈Pi⌉;a^(b*c-(c-b))-a*a^c-a

idea taken from here.

share|improve this answer
1  
That returns a list. To return only the desired string without using any numbers, try First@ToCharacterCode@"ߞ". That's 25 characters, 26 bytes. –  Michael Stern Jan 1 at 19:01
1  
@MichaelStern Hmm I would think a List is OK. –  Ajasja Jan 1 at 20:39
 
Nope, has to be the number itself. –  Joe Z. Jan 2 at 15:00
 
@MichaelStern Tr@ToCharacterCode@"ߞ". –  alephalpha Jan 2 at 15:59
 
@MichaelStern Thanks, great idea! JoeZ: Oh well:) –  Ajasja 2 days ago
add comment

Javascript, 18 characters

alert(btoa('ÛMx'))

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

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 2 days ago
 
@zzzzBov Yes, my original answer included an alert call. –  GOTO 0 yesterday
 
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 yesterday
 
@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 yesterday
 
@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 22 hours ago
add comment

D

ϯ has the numerical value 1007 in Unicode encoding.

as compiler message during compilation (20 chars)

pragma(msg,'ϯ'+'ϯ');

runtime version (45 chars)

import std.stdio;void main(){write('ϯ'+'ϯ');}
share|improve this answer
add comment

Golfscript - 11 10 chars

'&~I'{}/-*

computes 38 * 53 (ie an expansion of the prime factorization of 2014: 2 * 19 * 53)


Old Version

'f.'{}/.*\-

This computes 462-102.

'f.'{}/ puts the ascii values of f and . on the stack.
.*      squares the value of the .
\-      swaps the two values, then subtracts
share|improve this answer
 
Interestingly, the Befunge version of this Golfscript ('&~I'{}/-*), "&~I"-*.@, is one char longer than my Befunge answer and one character shorter than Golfscript. –  Quincunx Jan 1 at 10:33
1  
Note that 2*9=18; what you meant was 2*19=38. –  Kyle Kanos Jan 1 at 18:23
add comment

protected by Community Jan 1 at 22:35

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

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