634
\$\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 2025 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
  • 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\$ 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
  • 16
    \$\begingroup\$ I wonder if this question gets a small spike in popularity around New Year's. \$\endgroup\$ Commented Dec 26, 2015 at 23:28
  • 6
    \$\begingroup\$ Waiting for "Come on folks, don't you realize it's 2016?" :) \$\endgroup\$ Commented Jan 4, 2016 at 23:35

345 Answers 345

1
\$\begingroup\$

W j, 4 bytes

ë‘"C 

Explanation

ë‘" % Push a list C % Convert to list of ord codes [20,14] flag:j % Join without a separator ``` 
\$\endgroup\$
1
\$\begingroup\$

MathGolf, 2 bytes

ID 

Try it online!

Explanation

I # push 20 D # push 14 # implicit output 
\$\endgroup\$
1
\$\begingroup\$

Spice, 145 97 bytes

Improvement using multiplication to get the 9 from 2*2*2+1, as we already had those values.

;t;z;o;n;i@LEN i z;ADD i i i;LEN i o;PUT i i i;LEN i t;MUL t t i;MUL t i i;ADD o i n;OUT t z o n; 

Un-golfed explanation

;t;z;o;n;i@ - Declare vars LEN i z; - Get the length of [], 0, and store in z ADD i i i; - Adding implicitly uses the first element, or 0 if there is none, so we insert 0 into i LEN i o; - Store length of [0], 1, in o PUT i i i; - Insert 0th element of i into i at position i[0] (we're increasing the array size) LEN i t; - Store length of [0, 0], 2, into t MUL t t i; - Multiply t, 2, by itself and store in i MUL t i i; - Multiply t, 2, by i, 4, and store in i ADD o i n; - Add o, 1, to i, 8 and store in n OUT t z o n;- Write to console - "[2] [0] [1] [9]" 

Original

;t;z;o;n;i@LEN i z;ADD i i i;LEN i o;PUT i i i;LEN i t;PUT i i i;PUT i i i;PUT i i i;PUT i i i;PUT i i i;PUT i i i;PUT i i i;LEN i n;OUT t z o n; 

Un-golfed explanation

In Spice, all variables are double arrays. Importantly, variables that have no assigned value are either treated as an empty list [] or 0 depending on the operation. The built-in LEN will give the length of an array and we can therefore produce numbers:

;t;z;o;n;i@ - Declare vars LEN i z; - Get the length of [], 0, and store in z ADD i i i; - Adding implicitly uses the first element, or 0 if there is none, so we insert 0 into i LEN i o; - Store length of [0], 1, in o PUT i i i; - Insert 0th element of i into i at position i[0] (we're increasing the array size) LEN i t; - Store length of [0, 0], 2, into t PUT i i i; - Now repeat until there are 9 elements... PUT i i i; PUT i i i; PUT i i i; PUT i i i; PUT i i i; PUT i i i; LEN i n; - ... and store in n OUT t z o n; - Write to console - "[2] [0] [1] [9]" 

For the original 2014 version, you save bytes for less PUTs - 95 bytes. So this solution will improve next year!

\$\endgroup\$
1
\$\begingroup\$

FEU, 69 bytes

a/abcdeghij m/a/bb/b/cc/c/dd/d/ee/e/ff/f/gg/g/hh/h/ii/i/jj/j/kk/g U/k 

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Excel, 12

=UNICODE("ߞ 

Second best I could do was =ARABIC("MMXIV at 14 bytes.

\$\endgroup\$
1
\$\begingroup\$

Jelly, 10 bytes

⁹⁴×H_⁴Ḥ¤’’ 

Explanation:

⁹ Set the current value to 256. ⁴× Multiply by 16. The current value is now 4096. H Divide by 2. The current value is now 2048. _⁴Ḥ¤ Subtract by 16/2. The current value is now 2016. ’’ Decrement twice. The current value is now 2014. 
\$\endgroup\$
0
1
\$\begingroup\$

MAWP, 30 28 bytes

!!+!!!!++!*+/!+!!+!+!!++++*: 

Try it!

This will be fun to golf.

This is longer than @Lyxal 's answer, but outputs only one time as one number.

\$\endgroup\$
1
  • \$\begingroup\$ 15 bytes \$\endgroup\$ Commented Sep 28, 2020 at 9:10
1
\$\begingroup\$

Poetic, 112 bytes

two`s a bad thing using a two?o,hardly!i am using a poem a numeric poem?oh,clearly,but a limited one for certain 

Try it online!

\$\endgroup\$
1
\$\begingroup\$

DROL, 13 bytes

ziill<ukl<dfo

I wanted to add a language that wasn't already included...

DROL is a limited instruction assembler-like language with only two registers as storage. The language does include numbers, so it think it qualifies for this question. But numbers are only used for loop length indicators, as well as being used as the name of some instructions. It's described on the Esolang Wiki DROL page.

Here's a rundown of what the code does:

z set R1=0 ii increment R1 by 1 twice (2) ll square R1 three two (16) < shift left R1 (32) u set R2=R1 (32) k increment R2 (33) l square R1 (1024) < shift left R1 (2048) d decrement R1 (2047) f subtract R1 = R1 - R2 (2014) o print R1 as an integer 
\$\endgroup\$
1
\$\begingroup\$

Kotlin, 42 bytes

fun main()=print("ް.".map{it.code}.sum()) 

I used U+1968 which is ް and a . which is U+46.

\$\endgroup\$
1
\$\begingroup\$

Phooey, 16 bytes

=@+$i>$i=$i<@+$i 

Try it online!

 # Stk Tape =@+$i>$i=$i<@+$i # (0) >0 0 (initial state) = # (0) >1 0 tape = stack == tape to get 1 @ # 1 >1 0 push to stack + # (0) >2 0 pop; add stack to tape $i # (0) >2 0 print tape as integer (2) >$i # (0) 2 >0 move tape ptr right, print (0) =$i # (0) 2 >1 same as above to get 1 again, print (1) <@ # 2 >2 1 move back, push +$i # (0) >4 1 add stack to tape, print (4) 

Thank goodness for Phooey's = operator. This would be impossible in Foo.


Phooey, 23 19 bytes

This version actually generates the number 2014 instead of printing 2,0,1, and 4.

=@+@@@+@**@@*@+--$i 

Try it online!

 # stack | tape =@+@@@+@**@@*@+--$i # (0) | 0 initial state = # (0) | 1 tape = tape == pop() (to get 1) @+ # (0) | 2 double by adding to self @@ # 2 2 | 2 push two copies to the stack @+ # 2 2 | 4 double @* # 2 2 | 16 square by multiplying by self * # 2 | 32 multiply by 2 @ # 2 32 | 32 push 32 for later @* # 2 32 | 1024 square @+ # 2 32 | 2048 double - # 2 | 2016 pop and subtract - # (0) | 2014 pop and subtract $i # (0) | 2014 print 2014 
\$\endgroup\$
1
\$\begingroup\$

ARM assembly, 94 85 bytes (28 bytes compiled)

Textual assembly for ARM mode.

s:subs sb,sb adc sb,sb add sb,sb lsl sl,sb,sb add sb,sl,lsl sb rsb sb,sl,lsl sl bx lr 

A function which returns 2014 in sb (r9)

Clobbers sl (r10) and sb (r9).

Expanded version:

 // It feels so empty here... .globl s s: // use the quirky way subs affects the flags // to set r9 to 1 subs r9, r9, r9 adc r9, r9, r9 // double r9 by adding it to itself // lsl works just as well // r9 = 2 add r9, r9, r9 // r10 = r9 << r9 // r10 = 2 << 2 // r10 = 8 lsl r10, r9, r9 // r9 = r9 + (r10 << r9) // r9 = 2 + (8 << 2) // r9 = 2 + 32 // r9 = 34 add r9, r9, r10, lsl r9 // r9 = (r10 << r10) - r9 // r9 = (8 << 8) - 34 // r9 = 2048 - 34 // r9 = 2014 rsb r9, r9, r10, lsl r10 // Return bx lr 

This uses the same idea as my Phooey answer, of generating 2048, then subtracting 34. While I do have access to push and pop, ARM isn't a stack machine. It is a register machine. Additionally, we have lsl for shifting left which makes a few cases easier.

It is yet another rare case where the inverted carry flag on ARM is useful for something other than 64-bit subtraction, as it allows us to set a register to 1 when combined with adc.

Additionally, this only works in ARM mode: Thumb-2 did not show the return of shifting by register (which kinda was a dumb waste of encoding bits)

It uses the classic register names instead of the format which is r[0-15].

\$\endgroup\$
1
\$\begingroup\$

Python 3, 16 bytes

print(ord('ߞ')) 

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Vyxal, 10 3 bytes

»÷∩ 

Try it Online!

Simply the compressed number 2014

\$\endgroup\$
1
  • \$\begingroup\$ Can't be bothered to download the interpreter, but does !!!!!''.$... work for 11 bytes? \$\endgroup\$ Commented Oct 9, 2020 at 4:29
1
\$\begingroup\$

Grok, 13 bytes

iNH`I:P-zP-zq 

Alternate 13 Byte solution:

i:H:N`-Yx-zZq 
\$\endgroup\$
1
\$\begingroup\$

Branch, 11 bytes

}}#/#}#^}}# 

Try it on the online Branch interpreter!

Branch does have numbers in it. } is increment and { is decrement. # outputs as number. / goes to the left child, which is automatically initialized to 0, which is shorter than {{. Finally, ^ goes to the parent, which is 2 when that command is called. Actually, since the current node is 1, and the parent is 2, we could do ^}} or }}} to get 4.

An alternative solution that produces 2014 on the tree itself instead of outputting it character by character:

Branch, 50 bytes

}}^\}}}}}^*^\}}^*{^\}}^*^\/}}}}}}^\}}}}}}}}}^*{^*# 

Try it on the online Branch interpreter!

\$\endgroup\$
1
\$\begingroup\$

Deadfish~, 12 bytes

iioddoioiiio 

Try it online!

This, this is surprisingly short!

\$\endgroup\$
3
  • \$\begingroup\$ save bytes by squaring instead of incrementing twice at the end \$\endgroup\$ Commented Apr 24, 2021 at 15:21
  • \$\begingroup\$ This can just be vanilla deadfish, since you don't use ch{}(). Also, iiio can be replaced with iso for 11 bytes. \$\endgroup\$ Commented Apr 25, 2021 at 22:32
  • \$\begingroup\$ And you can get the number 2014: iiisddsddddsdddddddddddo but that's a bit long. \$\endgroup\$ Commented Apr 25, 2021 at 22:34
1
\$\begingroup\$

PICO-8, 24 18 bytes

?ord("⁙")*ord("j") 

ord() gets the numerical index of a character; in P8SCII, is at index 19 and j is at index 106, creating the equation \$19*106=2014\$.

\$\endgroup\$
1
\$\begingroup\$

Pascal, 76 B

See also Delphi.
This program requires a processor supporting ISO standard 10206 “Extended Pascal”, specifically constant definitions may be expressions (ord(true) is an expression).

program p(output);const I=ord(true);begin write(I+I,I-I:i,I:i,I+I+I+I:i)end. 

If ord(maxChar) ≥ 2014 we can use just one character in the 43 character program

program q(output);begin write(ord('X'))end. 

where X needs to be substituted by the implementation-defined char value having the ordinal value 2014.


For reference, an Extended Pascal program printing the current year looks like this:

program t(output); var t: timeStamp; begin getTimeStamp(t); writeLn(t.year) end. 
\$\endgroup\$
1
\$\begingroup\$

Go, 56 bytes

func f(){for _,c:=range`-+,/`{print(string(c+'F'-'A'))}} 

Attempt This Online!

Alternative to that other Go answer. Prints to STDERR.

\$\endgroup\$
1
\$\begingroup\$

Logically, 68 bytes.

@w:a,b,c;WRITE(h,a,b,c,l,h,h,l,l)() @M w(l,h)()w()()w(h)()w(l,l,h)() 

Consists of two gate definitions. w writes the 3 passed bits in the form of 00110cba, and then M has 4 w gates for each of the digits.

Whilst logically can use numbers for both argument unrolling and high-low states, it can be avoided pretty easily.

\$\endgroup\$
1
\$\begingroup\$

Thunno 2, 3 bytes

«¬ẓ 

Attempt This Online! Simple compressed integer.

Thunno 2, 4 bytes (UTF-8)

'ߞC 

Attempt This Online! Charcode.

Thunno, 4 bytes (UTF-8)

'ߞO 

Attempt This Online! Basically the same so I won't create another answer for it.

\$\endgroup\$
5
  • \$\begingroup\$ Thunno 2 HHHHHHHHHHHHHHHHHHHHTs, 1 byte: 4 \$\endgroup\$ Commented May 27, 2023 at 20:21
  • \$\begingroup\$ @Jacob you goofy - 4 is a digit and no digits allowed in the answer. You too noodles for golf. \$\endgroup\$ Commented May 27, 2023 at 23:55
  • \$\begingroup\$ @lyxal oops fixed it: Thunno 2, {"Z"*2014}l, 0 bytes. 🍜 \$\endgroup\$ Commented May 28, 2023 at 1:07
  • \$\begingroup\$ (and, in case it’s not clear, those are joke submissions and obviously unfair) \$\endgroup\$ Commented May 28, 2023 at 2:58
  • \$\begingroup\$ @Jacob lol, nice ones \$\endgroup\$ Commented May 28, 2023 at 6:59
1
\$\begingroup\$

!+~%, 8 bytes

++!+~%+! 

Stumbled over this challenge and sorry, could not resist. I promise this will not happen again. (-;

An explanation, to make this look serious:

  • ++ twice adds 7 to the initial 6, so we end up at 20, that gets printe by !
  • to the accumulator resetted to 6, + adds 7, and the ~ reverses the result from 13 to 31
  • % does a modulo from the number with a leading 1, so 131 mod 31 happens to be 7.
  • the + adds another 7, and ! prints the 14 behind the 20.
\$\endgroup\$
1
\$\begingroup\$

Vyxal 3, 3 bytes

~¥ᴴ 

Try it Online!

because of how the encoding works, vyxal 3 takes 4 bytes to use a base 252 encoding, but you can shave a byte because 2014 is only 2 bytes in base 255 and thus you can use the ~ element which converts 2 elements on the codepage to base 255

\$\endgroup\$
1
\$\begingroup\$

awk

gawk -p- -be 'BEGIN { print ++_+_--_++_++_^_ }' 

2014 

 # gawk profile, created Wed Oct 16 20:17:32 2024 # Rule(s) 1 { 1 print ++_+_--_++_++_^_ } 
\$\endgroup\$
4
  • 1
    \$\begingroup\$ gawk tuah code on that thang \$\endgroup\$ Commented Jan 7 at 9:42
  • \$\begingroup\$ @madeforlosers : this works on any awk not just gawk. I only performed 5 types of very basic operations - pre/post-inc/decrement, one addition, one exponentiation, gapless string concat, and to print it out to /dev/stdout. As weird as it looks, this is actually POSIX-compliant awk code. \$\endgroup\$ Commented Jan 12 at 13:05
  • \$\begingroup\$ it was a joke im sorry :( \$\endgroup\$ Commented Jan 13 at 16:55
  • \$\begingroup\$ @madeforlosers : no worries - i was thinking you're trying to make a joke but I couldn't figure out what the punch line is \$\endgroup\$ Commented Jan 16 at 5:46
1
\$\begingroup\$

JavaScript (Node.js), 33 bytes

alert([(a=-~'')+a]+~-a+a+(++a+a)) 

Attempt This Online!

\$\endgroup\$
5
  • \$\begingroup\$ (a+a+a+a) -> -~-~-~a chaining saves 2 bytes because precedence (I think) \$\endgroup\$ Commented May 7 at 10:37
  • \$\begingroup\$ Thanks, love the weird syntax :) discovered that (++a+a) also saves the 2 bytes. (I don't understand your es6 question...) \$\endgroup\$ Commented May 7 at 10:46
  • \$\begingroup\$ I meant more generally, that it doesn't use any Node.js features, so might as well just be an answer in JavaScript \$\endgroup\$ Commented May 7 at 11:00
  • 1
    \$\begingroup\$ Oh yeah, I just happened to use "attempt this online" which only has node. \$\endgroup\$ Commented May 7 at 11:02
  • \$\begingroup\$ Thinking if setting a=2 might save bytes, then [a]+0+1+4 might exist? Not sure (if you don't mind, if/when I figure this out, if it's before you I might post it as its own answer) \$\endgroup\$ Commented May 7 at 11:59
1
\$\begingroup\$

Base64, 9 Bytes

MjAxNA== 

(You can decode it with: echo MjAxNA== |base64 -d)

\$\endgroup\$
1
\$\begingroup\$

CASIO Basic (casio fx-9750giii), 28 20 16 bytes

₁₀Int π Ans+Ans+Int e^e^.!-.! 

its literally \$ 2(10^{\left\lfloor\pi\right\rfloor})+\left\lfloor e^{e^1}-1\right\rfloor \$

the ₁₀ character is not a proper number, as it's the single character version of 10^ so it can't be used like a 10 unless you do ₁₀1

just a period (.) on its own is equal to 0 (for some reason?). that means .! is equal to 1

Starts off with 1000 (₁₀Int π), multiplies it by 2 (Ans+Ans), adds 15 (+Int e^e^.!), and subtracts 1 (-.!) to get 2014.

CASIO Basic (Casio fx-9750giii), 12 bytes

this runs on 3 technicalities.

  1. it prints 2014.928947 which still kinda is 2014
  2. it requires you to press the EXE key (as opposed to the f1 key) to run the program
  3. the ² character is not a proper number in CASIO Basic
πGetkey²-₁₀Int π-π-.! 

and just for fun, heres 2014 with only .! (456 bytes) :3

(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)+(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)+(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)+(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)-√((.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!))-∛((.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!))-∛√((.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.!)(.!+.! 
\$\endgroup\$
1
\$\begingroup\$

tinylisp 2, 5 bytes

(h"ߞ 

Try It Online!

Explanation

The same character-code solution as everybody else. h is short for head, which, when given a string, returns the character code of its first character. The string quote and the function-call parenthesis both auto-close at the end of the line/program.

Non-string solution, 43 bytes

(d T(+(*)(* (d X(* T T T T T (-(* X X T)X T 

Try It Online!

Here, we take advantage of the fact that tinylisp 2's multiplication builtin * is variadic: it can take any number of arguments, including zero. Without arguments, its return value is the product of an empty list, or \$1\$.

(d T(+(*)(*))) 

Define T as the sum of \$1\$ and \$1\$, or \$2\$.

(d X(* T T T T T 

Define X as the product of five \$2\$s, or \$32\$.

(-(* X X T)X T 

Output the product of \$32\$ and \$32\$ and \$2\$, minus \$32\$, minus \$2\$ (the - builtin is also variadic): \$(32 \cdot 32 \cdot 2) - 32 - 2 = 2014\$.

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

Objective C

NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy"]; NSLog(@"%@",[formatter stringFromDate:[NSDate date]]); 
\$\endgroup\$
7
  • 1
    \$\begingroup\$ From the comments: Gelatin: “Is it acceptable to use the current year?” Joe Z.: “No, it has to be 2014 exactly.” \$\endgroup\$ Commented Jan 1, 2014 at 13:17
  • \$\begingroup\$ Because the question is a code-golf question, please add the character count. \$\endgroup\$ Commented Jan 1, 2014 at 13:31
  • 1
    \$\begingroup\$ What happened to you, Smalltalk ? You look...different. \$\endgroup\$ Commented Jan 7, 2014 at 1:17
  • \$\begingroup\$ NSLog(@"%i",'&'*('F'-'A')); \$\endgroup\$ Commented Feb 16, 2017 at 18:57
  • 1
    \$\begingroup\$ @Cœur sorry meant this NSLog(@"%i",'&'*('V'-'!')); \$\endgroup\$ Commented Mar 17, 2018 at 20:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.