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
  • 9
    \$\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
2
3 4 5
11
12
\$\begingroup\$

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.

\$\endgroup\$
5
  • \$\begingroup\$ Does it really take 3 characters to output the ascii codes for a string? That's sad :/ \$\endgroup\$ Jan 1, 2014 at 12:08
  • \$\begingroup\$ Printing 20 and 14 without separation is acceptable. \$\endgroup\$
    – Joe Z.
    Jan 7, 2014 at 1:37
  • 3
    \$\begingroup\$ I guess this can be actually shortened to 6 chars with {xy}.* where x and y represent 20 and 14 in ASCII. \$\endgroup\$
    – Vereos
    Jan 8, 2014 at 17:42
  • \$\begingroup\$ @Vereos, I somehow missed seeing your comment earlier. Very nice, and sufficiently different that it's worth posting as a separate answer. \$\endgroup\$ Mar 5, 2014 at 14:24
  • \$\begingroup\$ Alright, I will :) \$\endgroup\$
    – Vereos
    Mar 5, 2014 at 15:05
11
\$\begingroup\$

Haskell, 23 characters, 24 bytes

main=print$fromEnum 'ߞ'

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

\$\endgroup\$
3
  • \$\begingroup\$ According to codegolf.stackexchange.com/tags/code-golf/info, it has 24 characters. \$\endgroup\$ Jan 1, 2014 at 11:17
  • 2
    \$\begingroup\$ Methinks that's 23 characters, @GlitchMr, though it may be 24 bytes. \$\endgroup\$
    – TRiG
    Jan 1, 2014 at 18:18
  • \$\begingroup\$ @TRiG: Well, yes. The info page says that "If you use Unicode, byte count should use UTF-8." \$\endgroup\$ Jan 1, 2014 at 19:06
11
\$\begingroup\$

EXCEL, 24 characters:

=COLUMN(T:T)&COLUMN(N:N)
\$\endgroup\$
7
  • 1
    \$\begingroup\$ How does this even work? \$\endgroup\$
    – Timtech
    Jan 7, 2014 at 23:13
  • 2
    \$\begingroup\$ @Timtech T:T and N:N define an entire column, and COLUMN returns the column number of the reference passed in (of its top left cell, IIRC). & is string concatenation. \$\endgroup\$ Jan 8, 2014 at 3:15
  • \$\begingroup\$ Good job there :) \$\endgroup\$
    – Timtech
    Jan 8, 2014 at 11:50
  • \$\begingroup\$ How about the sheet references to shorten it even more? \$\endgroup\$ Jan 19, 2014 at 18:19
  • 1
    \$\begingroup\$ you can shorten to 16 bytes by using =COLUMN(BYL:BYL) \$\endgroup\$ Jul 12, 2017 at 10:06
11
\$\begingroup\$

Mathematica, 47 bytes

Total@ToCharacterCode@"Happy New Year for all!"

2014

\$\endgroup\$
3
  • \$\begingroup\$ If you remove the space between All and !, you can make All lowercase. \$\endgroup\$
    – Joe Z.
    Jan 3, 2014 at 0:33
  • \$\begingroup\$ @JoeZ. Yes!.. tks \$\endgroup\$
    – Murta
    Jan 3, 2014 at 0:35
  • 1
    \$\begingroup\$ That's pretty awesome. \$\endgroup\$ Jan 13, 2014 at 4:17
10
\$\begingroup\$

Mathematica (24)

Found by randomly generating expression trees. TraditionalForm chops 5 characters for the floor symbol but I think rich text doesn't count.

Floor[π E(Sin@E+E^E)E^E]
\$\endgroup\$
1
  • 1
    \$\begingroup\$ +1 Very nice! Pi counts as two chars (takes two bytes in UTF8, so it's 25 bytes). You can get it to 22 bytes by ⌊π*E(Sin@E+E^E)E^E⌋ (as you mentioned). \$\endgroup\$
    – Ajasja
    Jan 3, 2014 at 13:53
10
\$\begingroup\$

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.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ That returns a list. To return only the desired string without using any numbers, try First@ToCharacterCode@"ߞ". That's 25 characters, 26 bytes. \$\endgroup\$ Jan 1, 2014 at 19:01
  • 2
    \$\begingroup\$ @MichaelStern Hmm I would think a List is OK. \$\endgroup\$
    – Ajasja
    Jan 1, 2014 at 20:39
  • \$\begingroup\$ Nope, has to be the number itself. \$\endgroup\$
    – Joe Z.
    Jan 2, 2014 at 15:00
  • \$\begingroup\$ @MichaelStern Tr@ToCharacterCode@"ߞ". \$\endgroup\$
    – alephalpha
    Jan 2, 2014 at 15:59
  • \$\begingroup\$ @MichaelStern Thanks, great idea! JoeZ: Oh well:) \$\endgroup\$
    – Ajasja
    Jan 2, 2014 at 17:34
10
\$\begingroup\$

I and others have posted shorter Mathematica solutions to this challenge, but here are two methods that I don't believe have been tried in any of the other examples, in any languages.

Mathematica, 27 characters / 27 bytes

FromDigits["MMXIV", "Roman"]

Mathematica, 37 characters / 37 bytes

(ToString /@ FromDigits /@ {"K", "E"}) <> ""

and the following 58 character variation

FromDigits[Flatten[IntegerDigits /@ FromDigits /@ {"K", "E"}]]
\$\endgroup\$
2
  • \$\begingroup\$ 37 chars:(ToString /@ FromDigits /@ {"K", "E"}) <> "" By the way, why does FromDigits["K"] return 20?? \$\endgroup\$
    – DavidC
    Sep 23, 2014 at 2:25
  • \$\begingroup\$ @DavidCarraher Ah, 37 characters indeed, thank you. As for FromDigits["K"], "0"->0, "1"->1, "2"->2, "3"->3, "4"->4, "5"->5, "6"->6, "7"->7, "8"->8, "9"->9, "A"->10 etc. \$\endgroup\$ Sep 23, 2014 at 10:16
9
\$\begingroup\$

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('ϯ'+'ϯ');}
\$\endgroup\$
4
  • 1
    \$\begingroup\$ Couldn't you improve this by ditching the import and just qualifiying the write call (e.g., void main(){std.stdio.write('ϯ'+'ϯ');}) \$\endgroup\$
    – Travis
    Jan 10, 2014 at 2:14
  • \$\begingroup\$ No, the compiler still requires the import. \$\endgroup\$
    – mleise
    May 6, 2014 at 0:17
  • \$\begingroup\$ (late comment) Can you do pragma(msg,'ߞ'); and import std.stdio;void main(){write('ߞ');}? NOTE: ߞ IS U+07DE (2014). \$\endgroup\$ Jun 18, 2016 at 15:53
  • \$\begingroup\$ Arithmetical results are always widened to at least 32-bit integers, which is why the two character values add up and print as "2014". A single character retains its type and should be printed verbatim. \$\endgroup\$
    – mleise
    Aug 3, 2016 at 21:25
9
\$\begingroup\$

Java (68)

Solution 4: 68 chars (Thanks @radiodef))

class C{public static void main(String[]a){System.out.print(+'ߞ');}}

Solution 3: 69 chars (Thanks @Kamran)

class C{public static void main(String[]a){System.out.print(~~'ߞ');}}

Solution 2: 71 chars

class C{public static void main(String[]a){System.out.print('޾'+' ');}}

Solution 1: 72 chars

class C{public static void main(String[]a){System.out.print((int)'ߞ');}}

<3 Unicode.


Solution Derivation Technique: Copy the output from the following line and convert that character back to int for your a working solution.

System.out.println((char)2014));
\$\endgroup\$
11
  • 2
    \$\begingroup\$ Mine is better, without any numbers, and has 69 character. class C{public static void main(String[]a){System.out.print(~~'ߞ');}} \$\endgroup\$
    – Kamran
    Jan 9, 2014 at 10:29
  • 4
    \$\begingroup\$ By the way instead of the double complement, you can basically cheat and use the useless "positive" operator. System.out.print(+'ߞ'); All it will do is promote to int. \$\endgroup\$
    – Radiodef
    Jan 9, 2014 at 17:01
  • 1
    \$\begingroup\$ Note: This current answer produces text, not a Number object, as the question requested. \$\endgroup\$
    – djangofan
    Jan 10, 2014 at 0:55
  • 1
    \$\begingroup\$ Tip: you can use enum C{ instead of Class C{ Some IDEs think its a compiler error but it compiles flawlessly. that can result in another byte shaved off \$\endgroup\$
    – masterX244
    Mar 5, 2014 at 15:40
  • 1
    \$\begingroup\$ n->+'ߞ' for 8 bytes (7 characters), since lambdas are appropriate equivalents of a program. \$\endgroup\$ Aug 9, 2017 at 8:15
9
\$\begingroup\$

J - 11 bytes - Base arithmetic

+:_bj*p:_bf

Explanation

_bf and _bj are 15 and 19 in infinite base, therefore p:_bf is 15th prime, which is 53. The result is then 19*53 doubled, which is 2014.

J - 31 28 bytes - Math

(((!>:&+:)-(!>:))+:&+:)>.^*_

Explanation

The implementaion of A004126 sequence from OEIS where I searched for the ways to calculate 2014. Basically it's C(2*n+1,3)-C(n+1,3) where n=12.

This means ceiling(exp(signum(infinity))), which is 3

>.^*_

To get 12 we double it two times.

+:&+:

Everything else is a combo of a dyadic fork and monadic hook. You can read about them here.

Other's solution in J

+/(>.^*_)&u:'Happy new year to you!'

Which normally is +/3&u:'Happy new year to you!', it's a shame we need a number to work with strings.

It was fun to remember J :).

\$\endgroup\$
2
  • \$\begingroup\$ it's a shame we need a number to work with strings. You don't. You could do +/a.i.'Happy new year to you!' \$\endgroup\$ Jul 19, 2014 at 14:58
  • 2
    \$\begingroup\$ Another 11 char J solution: *./a.I.'&j'. \$\endgroup\$
    – randomra
    Dec 27, 2014 at 21:28
8
\$\begingroup\$

JavaScript 59, 44, 36, 29

a=+'';b=''+a+++a++;a+++b+ ++a

Assuming alert can be skipped due to implicit return


a=+'';b=''+a+++a++;alert(a+++b+ ++a)

alert([-~-~'',+'',-~'',-~-~-~-~''].join(''))

Those are l characters not 1
l='length';alert([[,,][l],[][l],[,][l],[,,,,][l]].join(''))
\$\endgroup\$
1
  • \$\begingroup\$ this is nice. +1 \$\endgroup\$
    – gion_13
    Jan 5, 2014 at 17:28
7
\$\begingroup\$

GolfScript, 10

I can't beat Quincunx's 10-char plain ascii solution but I can match it:

'N,,'{}/*+

(it calculates 44*44+78)

And now a different approach :)

'codegolfing is yummy'{+}*
\$\endgroup\$
1
  • 5
    \$\begingroup\$ Yet another 10-char solution: "xr"{`(;}% (free bonus smiley included!) \$\endgroup\$ Jan 1, 2014 at 14:58
7
\$\begingroup\$

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
\$\endgroup\$
2
  • \$\begingroup\$ Interestingly, the Befunge version of this Golfscript ('&~I'{}/-*), "&~I"-*.@, is one char longer than my Befunge answer and one character shorter than Golfscript. \$\endgroup\$
    – Justin
    Jan 1, 2014 at 10:33
  • 1
    \$\begingroup\$ Note that 2*9=18; what you meant was 2*19=38. \$\endgroup\$
    – Kyle Kanos
    Jan 1, 2014 at 18:23
7
\$\begingroup\$

AutoHotkey 31/13

send % ++(z:=true) z-z true z+z

This year special solution

send % A_year
\$\endgroup\$
1
  • \$\begingroup\$ 27 bytes: a:=Asc("")Asc(""), Send %a%. The characters in the Asc functions don't show correctly SE for me but they're the ASCII characters 20 and 14 copied and pasted into AHK. They show up as DC4 and SO (or maybe S0) in SciTE. \$\endgroup\$ Feb 24, 2017 at 18:53
7
\$\begingroup\$

Perl 6, 37 characters

This is not my actual solution (the real solution is in PHP, and is shorter), but I decided to make shorter version of Python's solution, because it's a really interesting idea.

say [+] ords 'Happy new year to you!'

So, what does it do? Well, it gets list of character positions (ords function), sums them together ([] is a reduce operator, which takes the exact operator between square brackets, in this case +), and say prints the result with new line. Could be WAY shorter by abusing ~^ prefix operator (which isn't implemented in Rakudo Perl) or Unicode characters, but this is just for fun solution.

Perl 6 is a quite an interesting language, even if it's not as good as Perl 5 in most code golf tasks (because of mandatory whitespace in many situations, and generally less DWIM). However, in this case, because of builtin sum and ords, it wins with Perl 5.

\$\endgroup\$
2
  • \$\begingroup\$ At first I thought you meant your solution was in Perl and was 6 characters long. And then I was like, "no, that can't be right." \$\endgroup\$
    – Joe Z.
    Jan 7, 2014 at 2:03
  • \$\begingroup\$ say ord "ߞ" is shorter but certainly less whimsical. \$\endgroup\$ Jan 13, 2015 at 17:02
7
\$\begingroup\$

R using roman numbers, 29 characters

as.numeric(as.roman('MMXIV'))
\$\endgroup\$
3
  • \$\begingroup\$ @plannapus yeah I know crazy idea :) Well, but quite normal in ancient times :) \$\endgroup\$
    – Tomas
    Jan 14, 2014 at 15:34
  • \$\begingroup\$ probably a "legacy" function :) \$\endgroup\$
    – plannapus
    Jan 14, 2014 at 15:35
  • 4
    \$\begingroup\$ Nice! There are 28 characters in as.double(as.roman('MMXIV')). \$\endgroup\$
    – djhurio
    Jan 15, 2014 at 7:11
6
\$\begingroup\$

JavaScript:

alert(+!![]+!![]+[+[]]+ +!![]+(+!![]+!![]+!![]+!![]));

each +!![] is 1 (![] is false, !false is true and +true is 1)

+[] is 0, and [0] is "0"

so this turns into 1+1+"0"+1+(1+1+1+1)

\$\endgroup\$
6
\$\begingroup\$

Python 3 (17 bytes)

print(ord("ߞ"))

Python 2 (50 bytes)

s,t=str,True;print s(t+t)+s(t-t)+s(t/t)+s(-~t<<t)
\$\endgroup\$
3
  • \$\begingroup\$ Python 2 version can be shortened to t=True;print't+t'+'t-t'+'t/t'+'-~t<<t', where the ' have to be changed to backticks. (I don't know how the enter real backticks that are shown as such). \$\endgroup\$ Jan 15, 2014 at 0:18
  • 1
    \$\begingroup\$ @WolframH wrap the code-block in an extra backtick. Like so: t=True;print`t+t`+`t-t`+`t/t`+`-~t<<t` where the initialization and end of the code block are done by use of: ``. Alternatively, replace every ` in the code with \`: t=True;print`t+t`+`t-t`+`t/t`+`-~t<<t` \$\endgroup\$
    – Justin
    Mar 5, 2014 at 6:06
  • 1
    \$\begingroup\$ Those are actually 16 and 49 bytes respectively. The trailing newline doesn't count. \$\endgroup\$
    – nyuszika7h
    Mar 15, 2015 at 20:04
6
\$\begingroup\$

guess this is already beaten but I like the approach:

<?php
$three=round(pi());
$one=pi()/pi();
$two=$three-$one;
$four=$three+$one;
$zero=$one-$one;
echo $two.$zero.$one.$four;
?>
\$\endgroup\$
6
\$\begingroup\$

Ruby — 8 characters

p ?ߞ.ord

where ߞ is Unicode character U+07DE — N'Ko letter ka.

This is what it looks like when I copy and paste the above line and run it in my Terminal. Notice the character does not display:

enter image description here

\$\endgroup\$
8
  • \$\begingroup\$ I understand what you're trying to do, but help me out... How do I test this? Copy & pasting your code doesn't work. If I copy & paste the little "07DE" Unicode char then I actually see \U+FFDF in irb, but that char has an ord of 85. \$\endgroup\$ Jan 1, 2014 at 20:30
  • 2
    \$\begingroup\$ This script prints nothing. \$\endgroup\$
    – tobyink
    Jan 2, 2014 at 15:36
  • 1
    \$\begingroup\$ How did you enter it? It works for me. Also, what version of Ruby are you using? \$\endgroup\$
    – O-I
    Jan 2, 2014 at 16:16
  • 1
    \$\begingroup\$ p ?ߞ.ord would meet the requirement of printing. \$\endgroup\$
    – steenslag
    Jan 3, 2014 at 18:55
  • 1
    \$\begingroup\$ this works for me \$\endgroup\$
    – mpapis
    Jan 3, 2014 at 20:04
6
\$\begingroup\$

C#, 60 characters

class a{static void Main(){System.Console.Write(- -'ߞ');}}

Thanks to mleise for the original answer for D!

Note: space between hyphens is important

\$\endgroup\$
10
  • 2
    \$\begingroup\$ if an exit code is acceptable class a{static int Main(){return - -'ߞ';}} is just 42 chars. \$\endgroup\$
    – Jodrell
    Jan 7, 2014 at 12:04
  • 7
    \$\begingroup\$ No need for "- -'ߞ'", could just do +'ߞ'. So: class a{static void Main(){System.Console.Write(+'ߞ');}} which is 56 bytes \$\endgroup\$
    – David_001
    Jan 7, 2014 at 13:00
  • 1
    \$\begingroup\$ If we want to get without using the ASCII characters this is simple, int i; i = " ".Length; Console.WriteLine(i + "" + ((i-i)) + "" + --i + "" + ++i*i); \$\endgroup\$ Jan 8, 2014 at 6:33
  • 1
    \$\begingroup\$ @JuliaHayward and it will also fail this contest this year... (Reread the OP). \$\endgroup\$ Jan 13, 2014 at 3:43
  • 1
    \$\begingroup\$ OK, tongue-in-cheek comment failed utterly \$\endgroup\$ Jan 13, 2014 at 9:38
6
\$\begingroup\$

Raku (Perl 6), 12 bytes

say 'ߞ'.ord
\$\endgroup\$
5
\$\begingroup\$

Javascript (29 chars)

t=!'',a=t+t+'';a+!t*t+t*t+a*a

Not the shortest but some boolean logic

\$\endgroup\$
3
  • \$\begingroup\$ That was my first idea too haha. This is the best I could get: a=!'';a+a+""+(+!a)+(+a)+(a+a+a+a) (33 chars) \$\endgroup\$
    – Benno
    Jan 11, 2014 at 12:44
  • \$\begingroup\$ @Benno (+!a) is pretty clever, didn't know it works like this \$\endgroup\$
    – Rob Fox
    Jan 11, 2014 at 16:37
  • \$\begingroup\$ Yeah, it seems to treat it as an integer, only when in brackets though! Without the brackets, it reverts to 2falsetruetruetruetruetrue ;) \$\endgroup\$
    – Benno
    Jan 13, 2014 at 5:56
5
\$\begingroup\$

T-SQL, 50 40

My original entry seems too straightforward. How's this?

PRINT RIGHT(CHECKSUM(',,.'),LEN('````'))

(Disclaimer: Given Steve Matthews's comment, the above may be dependent on configuration.)

Here's the SELECT version in SQL Server 2012.

Original entry:
This may look obscene in more ways than one, but it's valid.

DECLARE @ INT=\PRINT CONCAT(-~-~@,@,-~@,-~-~-~-~@)

Try it in SQL Server 2012. Here is a version using SELECT.

Explanation: "\" is a valid currency symbol. (Do a find for "String to" here.) If you assign just a currency symbol to an INT variable, you store 0. Also, "@" is a valid variable name. "~" is bitwise NOT, and "-" is negative. If you negate a NOT-ed INT, you get the INT plus 1. So, repeat "-~" until you make @ into the digit you need. Then CONCAT() your digits.

\$\endgroup\$
5
  • \$\begingroup\$ Running PRINT RIGHT(CHECKSUM(',,.'),LEN('````')) on MS SQL Server 2008 R2 produces the response "1200" \$\endgroup\$ Dec 1, 2015 at 10:15
  • \$\begingroup\$ Can I suggest instead something like PRINT ASCII('')*ASCII('j') which is just 27 bytes (note that the character that isn't rendered here is the DC3 CHAR(19) in the first set of quote marks. \$\endgroup\$ Dec 1, 2015 at 10:34
  • \$\begingroup\$ @Steve I actually ran the checksum one on the same version, too, but you touch on a good point that maybe the checksum algorithm could vary based on configuration. I should add a disclaimer. Also, I like your better 27-byte solution. You should post it as an answer so people can vote it up. \$\endgroup\$
    – Muqo
    Dec 1, 2015 at 18:59
  • \$\begingroup\$ PRINT UNICODE(N'ߢ') has 20 bytes \$\endgroup\$
    – Jan Drozen
    Nov 9, 2018 at 13:33
  • \$\begingroup\$ @JanDrozen Very nice, but you must've meant 'ߞ'. \$\endgroup\$
    – Muqo
    Nov 13, 2018 at 0:15
5
\$\begingroup\$

Japt, 3 bytes (2 chars)

Japt is newer than this competition (created in 2015), but was not created specifically to answer it.

That's right. 2 chars. Explanation:

#   // Char-code of next character
 ߞ  // Character with char-code of 2014
    // Implicit output

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Does this mean I can undelete my Microscript answer? \$\endgroup\$ Dec 9, 2015 at 2:25
  • \$\begingroup\$ @SuperJedi224 There's a list in the main post of "invalid but interesting answers". I think newer languages fall into this category. \$\endgroup\$ Dec 9, 2015 at 2:31
5
\$\begingroup\$

Vim 7.4, 18 bytes

:h os_v<CR>$bbbyiwZZp

Here, <CR> means a literal newline. Uses the help page os_vms.txt which contains the number 2014 on the first line.

How it works:

:h os_v<CR>            This opens the help page for os_vms.txt, the line the cursor lands on contains '2014'.
           $bbb        Move the cursor to the '2014' (end-back-back-back)
               yiw     Copy it (yank-in-word)
                  ZZ   Close the help page
                    p  Paste the copied word

If numbers were allowed we could do:

i2014
\$\endgroup\$
9
  • \$\begingroup\$ It's 2010 for me instead \$\endgroup\$
    – user41805
    Dec 18, 2016 at 13:17
  • \$\begingroup\$ @KritixiLithos Weird, it works for me. What help page does :h os_v open for you? \$\endgroup\$
    – Loovjo
    Dec 18, 2016 at 13:18
  • 1
    \$\begingroup\$ It opens os_vms.txt says Vim version 7.3 and last change was made in 2010 Jul 8 \$\endgroup\$
    – user41805
    Dec 18, 2016 at 13:24
  • \$\begingroup\$ What version of Vim are you using? \$\endgroup\$
    – Loovjo
    Dec 18, 2016 at 13:26
  • 2
    \$\begingroup\$ If numbers were allowed you could just do i2014. :P \$\endgroup\$
    – Joe Z.
    Dec 18, 2016 at 21:01
5
\$\begingroup\$

Javascript, 37 bytes

((_=+!![])<<''+_+''+_)-(_<<_+++_+_)-_

It's not code golf until someone bitshifts.

$ node
> ((_=+!![])<<''+_+''+_)-(_<<_+++_+_)-_
2014

It is actually Javascript, I promise.

((_=+!![])    // create 1 and save in _
  <<          // left bitshift by 11 to get 2048
    ''+_+''+_ // create 11 from '1' + '1'
  )           
  -           // subtract (2048 - 32) === 2016
  (
    _<<       // bitshift by 5 to get 32
  _+++_+_     // create 5 from 1 + (++1) + 2
)-_           // subtract 2 to get 2014
\$\endgroup\$
1
  • 2
    \$\begingroup\$ That looks so much like Brainfuck. \$\endgroup\$
    – Joe Z.
    Oct 19, 2014 at 14:59
5
\$\begingroup\$

TI-BASIC, 12 bytes

A completely new approach.

iPart(π+iPart(e)sinh(π+√(π

This could probably be golfed further, using a 1-byte token in place of e, but I have spent far too long on this today...

\$\endgroup\$
4
\$\begingroup\$

Ruby:

p eval("#{""=~//}x#{"\a".ord}de")

Here is how it works inside IRB shell:

>> p eval("#{""=~//}x#{"\a".ord}de")
2014
\$\endgroup\$
4
\$\begingroup\$

J (18)

This one doesn't use any character codes. Uses the idea that the sum of the sequence of natural numbers from 1 -> 63 = 2016.

<:<:+/i.*:+~+~p:%_
\$\endgroup\$
1
  • \$\begingroup\$ You could save two bytes <:<:+/i.*:+~dyad \$\endgroup\$
    – FrownyFrog
    Nov 18, 2017 at 16:50
1
2
3 4 5
11

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