607
\$\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 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\$
15
  • 16
    \$\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
  • 8
    \$\begingroup\$ I know. That's why I posted it as a comment \$\endgroup\$ Apr 1, 2015 at 22:51
  • 11
    \$\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
  • 3
    \$\begingroup\$ Waiting for "Come on folks, don't you realize it's 2016?" :) \$\endgroup\$
    – padawan
    Jan 4, 2016 at 23:35

309 Answers 309

1
7 8 9 10
11
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\$

C++ (gcc), 33 bytes

main(){std::cout<<('j'-'W')*'j';}

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Should #include <iostream> be included as byte count? \$\endgroup\$
    – tsh
    Feb 11 at 9:26
  • \$\begingroup\$ Might as well go for putting \x13 in your source! -6 bytes \$\endgroup\$
    – M Virts
    Jun 11 at 21:59
  • \$\begingroup\$ @tsh I agree the include should be part of it. In the same vein you could just switch to C \$\endgroup\$
    – M Virts
    Jun 11 at 22:01
-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.