618
\$\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 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>

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

320 Answers 320

1
7 8 9 10
11
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
    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\$ 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
    Jul 5, 2019 at 16:49
  • \$\begingroup\$ @MilkyWay90 Answers are not required to be in a programming language \$\endgroup\$ 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
    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\$
0
\$\begingroup\$

Neim, 4 2 bytes

χρ

Try it online!

Push 20, push 14 and print the entire stack

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

BRASCA, 4 bytes

'ߞn

Try it online!

Explanation

'ߞ   - Push the character ߞ (Codepoint 2014)
  n  - Print as number

Alternative solution, 9 bytes

ll+'.E-Sn

Try it online!

Explanation

ll+         - 10+10 = 20
   '.E-     - code point 46-32  = 14
       S    - Concatenate 20 and 14
        n   - Print as number
\$\endgroup\$
3
  • 1
    \$\begingroup\$ According to Wikipedia, 1 is a number. I don't know how accurate it is, though. \$\endgroup\$
    – EasyasPi
    Jan 28, 2021 at 13:25
  • \$\begingroup\$ I'm too used to those dang numbers. \$\endgroup\$ Jan 28, 2021 at 13:36
  • \$\begingroup\$ It's now fixed. No more stray numbers. \$\endgroup\$ Jan 28, 2021 at 13:48
0
\$\begingroup\$

awk

mawk 'BEGIN { print (_+=++_)!_!!_ _^_ }'

2014
\$\endgroup\$
3
  • 3
    \$\begingroup\$ Why do you obstinately refuse to follow our established standards of formatting solutions? How many bytes is this? How do I test it? \$\endgroup\$
    – Shaggy
    May 26 at 21:39
  • \$\begingroup\$ This doesn't seem to work on Try it Online. Am I doing something wrong? \$\endgroup\$
    – The Thonnu
    May 27 at 17:59
  • \$\begingroup\$ TIO link (after removing usless whitespace), byte count seems to be 29,,, \$\endgroup\$ May 27 at 21:39
0
\$\begingroup\$

Desmoslang Assembly, 15 Bytes

PDPP+PDDP+P+POT

\$\endgroup\$
-1
\$\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
    Sep 27, 2016 at 15:46
  • \$\begingroup\$ You can't type ^S in a Linux terminal. -1 \$\endgroup\$
    – MD XF
    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\$ May 22, 2017 at 14:29
1
7 8 9 10
11

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