630
\$\begingroup\$

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 2022 2023 2024 already, folks, go home.

Woo, 10 years of this challenge!

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>

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

341 Answers 341

1
8 9 10
11
12
0
\$\begingroup\$

C, 25 bytes

f(){printf("%d",L'ߞ');}

24 characters, but one character is UTF-8 encoded. Still the shortest C answer! How it works:

U+07DE ߞ NKO LETTER KA

7DE in decimal is 2014.

\$\endgroup\$
0
\$\begingroup\$

C, 29 bytes (Emacs) / 40 bytes (VI)

Before creating program, execute the shell command

stty -ixon      ### 11 bytes, with the newline

N.B this is required for most terminal editors, but is not required for emacs

then write this code:

main(){printf("%d",'j'*'^S');}

N.B. '^S' is a single XOFF character e.g. in VI use control-V, control-S; in emacs use control-Q, control-S; emacs turns off flow control by default.

I assume the comment [You can't type ^S in a Linux terminal] below left off an implied [without the stty command or equivalent e.g. emacs default behavior upon startup], otherwise that comment is inaccurate.

And here is the requested hexdump:

$ od -a -t x1 x.c
0000000   m   a   i   n   (   )   {   p   r   i   n   t   f   (   "   %
         6d  61  69  6e  28  29  7b  70  72  69  6e  74  66  28  22  25
0000020   d   "   ,   '   j   '   *   ' dc3   '   )   ;   }  nl
         64  22  2c  27  6a  27  2a  27  13  27  29  3b  7d  0a
\$\endgroup\$
3
  • 2
    \$\begingroup\$ This isn't a valid answer. You have to count the shell command also, since it's a non-standard configuration. Also, if you have unprintables in your code, you should include a hexdump, for extra clarity. \$\endgroup\$
    – user45941
    Commented Sep 27, 2016 at 15:46
  • \$\begingroup\$ You can't type ^S in a Linux terminal. -1 \$\endgroup\$
    – MD XF
    Commented May 21, 2017 at 23:37
  • 1
    \$\begingroup\$ There is more than one way to ^Skin a cat, so these comments are incorrect as written; I clarified my post to address the confusion these folks (and others) may be having. It's still 29 if you use emacs as an editor. MD XF: how do you enter your [U+07DE] character into C-source; also, my compiler throws an error when replacing [main()] with [f()] (excluding the obvious gcc -Df=main hack), but if there is a compiler that accepts [f()], then all C source scores drop by 3. So you need to bump your score by 3, or reduce all other C solutions. \$\endgroup\$ Commented May 22, 2017 at 14:29
0
\$\begingroup\$

Python 3, 16 Bytes :

print(ord('ߞ'))

2017 version, 16 Bytes :

print(ord('ߡ'))
\$\endgroup\$
0
\$\begingroup\$

Whitespace, 19 bytes

Visible representation:

SSSTTTTTSTTTTSNTNST

Just pushes 2014 onto the stack and prints it. Whitespace's lack of any visible characters makes this pretty easy.

Valid as numbers are completely valid tokens in whitespace, they just don't do anything.

\$\endgroup\$
0
\$\begingroup\$

Common Lisp, 15 characters

(char-code #\ߞ)

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Clojure - 35 characters ASCII only

(print(-(*(int\#)(int\<))(int\V)))

Based on True Soft's answer

\$\endgroup\$
0
\$\begingroup\$

Ruby (8 bytes, 7 chars)

'ߞ'.ord

The question mark is ߞ represented in two bytes UTF8.


Short Ruby

\$\endgroup\$
7
  • \$\begingroup\$ Duplicate of O-I's Ruby solution posted 3.5 years earlier. \$\endgroup\$
    – manatwork
    Commented Jul 24, 2017 at 9:24
  • \$\begingroup\$ @manatwork Duplicate answers are allowed. \$\endgroup\$ Commented Jul 24, 2017 at 10:44
  • \$\begingroup\$ I didn't said they aren't. Neither downvoted or flagged. (Just for the record, I never agreed with that rule. And never will.) But I think would be more enjoyable to avoid duplicated solutions. Especially on a question that already has 263 answers. \$\endgroup\$
    – manatwork
    Commented Jul 24, 2017 at 11:03
  • \$\begingroup\$ Hm... hard to find the old solutions. But actually his solution is 9 bytes because the codepoints representations need 2 bytes. \$\endgroup\$
    – schmijos
    Commented Jul 24, 2017 at 12:58
  • 1
    \$\begingroup\$ Initially O-I's solution was also 'ߞ'.ord, but then be updated because the requirement says to “prints the number 2014”. The general rule (which can be overridden by each challenge) is that solutions must handle input and output either themselves explicitly or benefit the interpreter's service if it has such thing like ruby's -n or -p. Code that expects input to be readily available in the memory or just leaves the value they produce in the memory are called snippets and generally are not accepted as solutions. \$\endgroup\$
    – manatwork
    Commented Jul 24, 2017 at 14:29
0
\$\begingroup\$

Implicit, 3 bytes

Try it online!

     implicit push command
`    character
 ߞ   U+07DE (2014 in decimal)
     implicit integer output
\$\endgroup\$
0
\$\begingroup\$

Triangularity, 18 bytes

.. ..
."ߞ".
o    

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Pyt, 16 bytes

áŁ!⁺²Đ⁺⁺!₀⁻⁻⇹ᴇ+₅

Explanation:

á                               Push stack into list (pushes empty list)
 Ł                              Get length of top of stack (0)
  !                             0!=1
   ⁺²                           (1+1)^2=4
     Đ                          Duplicate top of stack
      ⁺⁺!                       (4+2)!=720
         ₀⁻⁻                    720/10-2=70
            ⇹                   Swap top two items on stack (4 is on top)
             ᴇ                  10^4=10000
              +₅                (10000+70)/5=2014

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Brainf*ck

>++++++++++[<+++++>-]<.--.+.+++.

More readable version:

> Move pointer pos over
++++++++++ Add 10
[ Start loop
<+++++>- Add 5, move over & subtract 1
] End loop
<.--.+.+++. Do some other stuff

Yes, I know this is an old post, but I'm really bored and want to get enough rep to comment because I don't have access to my other account.

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to PPC...Jk \$\endgroup\$
    – qqq
    Commented Jan 12, 2018 at 3:11
0
\$\begingroup\$

Brainfuck, 23 Bytes

-[>+<-----]>-.--.+.+++.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Aceto, 10 bytes

IIppIpPiIp

Try it online!

Uses int(Pi) to it's advantage

11 bytes (previous answer)

IIppIpIIIIp

Try it online!

Simply increments from zero 2, 0, 1, and 4 times, then prints each time

Fun Version

Piddd++DsJiPidIIJi*p

Try it online!

Uses int(Pi) to base equations off of

Lame Version

'ߞop

Try it online!

Converts the codepoint to number, which is 2014

\$\endgroup\$
0
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 42 bytes

	&UCASE 'N' @X ARB 'T' @Y
	OUTPUT =Y X
END

Try it online!

@ assigns the index of the match and (space) concatenates them.

I know, it's 2018, so I should go home...

\$\endgroup\$
0
\$\begingroup\$

Python 3, 16 bytes

lambda:ord('ߞ')

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Objective-C, 27

NSLog(@"%i",'&'*('V'-'!'));
\$\endgroup\$
0
\$\begingroup\$

x86, 15 bytes

No numbers in the source code. Returns in eax. Uses (252*4 - 1) * 2.

   0:   31 c0                   xor    %eax,%eax
   2:   fe c8                   dec    %al
   4:   48                      dec    %eax
   5:   48                      dec    %eax
   6:   48                      dec    %eax
   7:   d1 e0                   shl    %eax
   9:   d1 e0                   shl    %eax
   b:   48                      dec    %eax
   c:   d1 e0                   shl    %eax
   e:   c3                      ret  

If we permit numbers in the source but not binary, we have mov $2014,%ax/ret for 5 bytes.

\$\endgroup\$
0
\$\begingroup\$

Ahead, 5 bytes

ezpz

'ߞO@

' push next cell to stack
ߞ U+7DE (2014 decimal)
O output as number
@ die

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Z80Golf, 10 bytes

00000000: 080a 0b0e 767e 23e5 ee3a                 ....v~#..:

Try it online!

Disassembly

start:
  ex af,af'  ; db $3a ^ '2' ($08)
  ld a,(bc)  ; db $3a ^ '0' ($0a)
  dec bc     ; db $3a ^ '1' ($0b)
  ld c,$76   ; db $3a ^ '4' ($0e)
             ; halt         ($76)
  ld a,(hl)
  inc hl
  push hl
  xor $3a

Essentially the Hello World trick in Z80Golf.

In short, hl serves two purposes: data address for a and return address for putchar (which is at $8000 and accessed by going all the way through zeroed memory, instead of call $8000).

The instructions in the data section have to be effective no-ops (not touching hl and sp should suffice), and the last one should be 2-byte in order to shadow $76 (halt). I carefully selected the xor value so that the resulting binary has no digits ($30 to $39).

Z80Golf, 10 bytes, 2018 edition

00000000: 1416 171e 767e 23e5 ee26                 ....v~#..&

Try it online!

Disassembly

start:
  inc d      ; db $26 ^ '2' ($14)
  ld d,$17   ; db $26 ^ '0' ($16)
             ; db $26 ^ '1' ($17) ; rla
  ld e,$76   ; db $26 ^ '8' ($1e)
             ; halt         ($76)
  ld a,(hl)
  inc hl
  push hl
  xor $26

Same principle, but this time we can't use ld c,$76 since it gives $36 for the xor value. So I moved to e which starts with 1e. Also, different starting address gives two different interpretations of the data section:

  • $16 $17: ld d,$17
  • $17: rla (Rotate the register A to the left)

So I had to check both are effective no-ops in this program.

\$\endgroup\$
0
\$\begingroup\$

Lua 5.3.1, 31 bytes

It's an old question, but I may as well join in on the fun!

For those not familiar with Lua, the # operator returns the length of an array or string, and the .. operator is for string and number concatenation. The // operator is integer divide, and is used so that there is no trailing decimal in the numbers caused by Lua treating the result of regular divisions as a float.

2014 in 31 bytes: t=#"aa"print(t..t-t..t//t..t*t) = print(2..2-2..2/2..2*2)

2015 in 36 bytes: t=#"aa"print(t..t-t..t//t..t*t+t//t) = print(2..2-2..2//2..2*2+2/2)

2016 in 33 bytes: t=#"aa"print(t..t-t..t//t..t*t+t) = print(2..2-2..2//2..2*2+2)

2017 in 38 bytes: t=#"aa"print(t..t-t..t//t..t*t+t+t//t) = print(2..2-2..2//2..2*2+2+2/2)

2018 in 33 bytes: t=#"aa"print(t..t-t..t//t..t*t*t) = print(2..2-2..2//2..2*2*2)

The solutions for other years are pretty similar. Here's a function that can do any number:

function f(y)
    t=#"a"
    s=""
    for i=t, #(y.."") do
        n=t-t
        for j=t,(y..""):sub(i,i) do
            n=n+t
        end
        s=s..n
    end
    return s
end

And here's the golfed version of the function at 108 bytes:

function f(y)t=#"a"s=""for i=t,#(y.."")do n=t-t for j=t,(y..""):sub(i,i)do n=n+t end s=s..n end return s end

\$\endgroup\$
0
\$\begingroup\$

;# - 203

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
\$\endgroup\$
4
  • \$\begingroup\$ This language is invalid according to the community consensus on what counts as a programming language \$\endgroup\$
    – MilkyWay90
    Commented Jul 5, 2019 at 4:33
  • \$\begingroup\$ @MilkyWay90 Um, this is from just under a year ago... I don't think there was a consensus back then. Either way, it's not like i even got an upvote, so let's just leave it, eh? \$\endgroup\$ Commented Jul 5, 2019 at 16:46
  • \$\begingroup\$ The consensus was made in 2014. You can take it up with Meta, but until then this is invalid \$\endgroup\$
    – MilkyWay90
    Commented Jul 5, 2019 at 16:49
  • \$\begingroup\$ @MilkyWay90 Answers are not required to be in a programming language \$\endgroup\$ Commented Sep 30, 2020 at 2:42
0
\$\begingroup\$

K (ngn/k), 10 bytes

"&"*-/"U "

Try it online!


and 2018 just because this is so late

K (ngn/k), 11 bytes

-"^"-*/"@!"

Try it online!


EDIT: I'm unsure when this language was created, it's a variant of k which has existed for a long time, but the gitlab link seems to indicate that it may be only a year or so old (judging by commit info), so this answer may be invalid as a result

\$\endgroup\$
1
  • \$\begingroup\$ The non-competing rule has been abolished \$\endgroup\$
    – MilkyWay90
    Commented Jul 5, 2019 at 4:33
0
\$\begingroup\$

Aheui (esotope), 8 chars (24 bytes)

반밝따바뱟해망어

Try it online!


It's too easy for Aheui since it never use any kind of digits at all.

Explanation:

# An Aheui code starts with default stack "아".
반: push 2, move cursor right by 1(→).
밝: push 7, →
따: mul(push 14), →
바: push 0, →
뱟: push 2, move cursor right by 2(→→).
해: end.
망: print as integer, →
어: move cursor left by 1(←).

Note: Print instruction moves cursor in reverse direction if current storage is empty.

\$\endgroup\$
0
\$\begingroup\$

TI-BASIC, 7 bytes

int(₁₀^(³√(tan(cosh(cos(π

A significant improvement from the previously winning 12-byte TI-BASIC answer. Using one-byte functions allows the greatest number of chances to achieve a certain value within a given byte count.

\$\endgroup\$
0
\$\begingroup\$

Forth, 29 bytes

hex fbc 'B' '!' / / decimal .

Try it online!

\$\endgroup\$
0
\$\begingroup\$

C# .NET 75 bytes

public class p{public static void Main(){System.Console.Write((int)'ߞ');}}

Just displaying the integer value of the unicode character ߞ
Try online (also has 2015-2019)

\$\endgroup\$
0
\$\begingroup\$

*nix shell (POSIX/bourne) 41 bytes

a=.. c=. d=....;echo ${#a}${#b}${#c}${#d}

Other solutions

printf %x \'— # 13 characters Try it online!
echo $[x=++y+y]$?$y$[x+x] # 25 characters Try it online!

\$\endgroup\$
0
0
\$\begingroup\$

HaykamScript, 11 bytes

s[⛉,☄]i

Explanation

s       - string
  [     - executed parameters
    ⛉   - constant for 201
    ,
    ☄   - constant for 4
  ]
i       - convert to integer

Other Years

It's pretty simple to make any other year with the same amount of bytes, Unicode codepoints 0x2600 to 0x26FF represent integers 0 to 255 in my language.

For example, to make the year this was posted:

s[⛉,☈]i
\$\endgroup\$
0
\$\begingroup\$

k4, 20 bytes

*/(-)."j"$("Ud";"/")

      "j"$("Ud";"/") / convert "Ud" and "/" to underlying integer representation -> (85 100;47)
  (-).               / subtract 47 from 85 and 100 -> 38 53
*/                   / multiply over
\$\endgroup\$
0
\$\begingroup\$

MAWP 2.1, 15 bytes

!+!:!!-:!!$:!+:

Try it online lol.

\$\endgroup\$
1
8 9 10
11
12

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