619
\$\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
  • 23
    \$\begingroup\$ Even though numbers are ignored in brainfuck, I thought I'd post one anyway. 32 Chars: ++++++[>++++++++<-]>++.--.+.+++. \$\endgroup\$ Apr 1, 2015 at 21:37
  • 7
    \$\begingroup\$ Brainfuck isn't a valid language for this challenge. \$\endgroup\$
    – Joe Z.
    Apr 1, 2015 at 22:49
  • 14
    \$\begingroup\$ I know. That's why I posted it as a comment \$\endgroup\$ Apr 1, 2015 at 22:51
  • 13
    \$\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
  • 5
    \$\begingroup\$ Waiting for "Come on folks, don't you realize it's 2016?" :) \$\endgroup\$
    – padawan
    Jan 4, 2016 at 23:35

328 Answers 328

1 2 3
4
5
11
3
\$\begingroup\$

J (13)

#.a.i.'_!!! '

Interprets the ASCII value of _!!! (95 33 33 33 32) as a binary number (it's weird that this is possible, I agree). This produces 2014.

J (15)

This one doesn't use any character strings. It's based on the weird coincidence that the sum of the first 46 primes is 4028: double 2014.

-:+/p:i.<:+:_bn

If anyone knows of a shorter way than <:+:_bn to represent 45 (preferably without strings), please let me know.

\$\endgroup\$
3
\$\begingroup\$

Python 2, 68 bytes

Not really short, but it abuses the fact that Python accepts booleans where an integer is required, because bool is a subclass of int.

import string;d=string.digits;T=True;print d[T+T]+d[:T+T]+d[T+T+T+T]
\$\endgroup\$
3
  • \$\begingroup\$ +1 for the first non-cheating program in this question that doesn't depend on ASCII or UTF-8 (unless I missed something) \$\endgroup\$ Jan 1, 2014 at 21:54
  • \$\begingroup\$ False can be shortened to d>d. On the other hand, d[d>d]+d[T] can be shortened to d[:T+T], so that optimization is not really necessary ;-). Also, from string import*;d=digits;saves one character. \$\endgroup\$ Jan 15, 2014 at 0:12
  • \$\begingroup\$ @WolframH Noted. I'll update it later. \$\endgroup\$
    – Alexia
    Jan 21, 2014 at 21:49
3
\$\begingroup\$

Excel VBA, 51 bytes

MsgBox Len("aa") & Len("") & Len("a") & Len("four")

As it's 2015 you could add an extra character onto "four" for an extra byte.

\$\endgroup\$
3
\$\begingroup\$

MATLAB (no char codes), 47 chars

p=pi,q=p^p;e=exp(p);floor(q*q+q*e-q-q-q-p-e-e)
\$\endgroup\$
2
  • \$\begingroup\$ I played with a similar approach in Mathematica (which has a much larger set of mathematical constants built-in). How long did it take you to develop that solution. \$\endgroup\$ Jan 2, 2014 at 22:46
  • \$\begingroup\$ Just playing around, maybe five minutes, probably less. I’m pretty sure this is far from the most compact formula. \$\endgroup\$ Jan 3, 2014 at 13:13
3
\$\begingroup\$

C++, 50 bytes

#include<iostream>
int main(){std::cout<<'U'^'A';}
\$\endgroup\$
9
  • \$\begingroup\$ You should provide compile-ready code in C++. \$\endgroup\$
    – Joe Z.
    Jan 1, 2014 at 5:24
  • \$\begingroup\$ Also, use four spaces before each line for blocks of code. \$\endgroup\$
    – Joe Z.
    Jan 1, 2014 at 5:29
  • \$\begingroup\$ i added "iostrean but it disappeared, actually am new so don't know how to" \$\endgroup\$ Jan 1, 2014 at 5:29
  • 6
    \$\begingroup\$ This is supposed to be code golf, i.e. shortest code possible. Remove unnecessary whitespace, etc \$\endgroup\$
    – Doorknob
    Jan 1, 2014 at 5:32
  • \$\begingroup\$ @DoorknobofSnow thanx, after your edition i can still see few extra spaces \$\endgroup\$ Jan 1, 2014 at 5:34
3
\$\begingroup\$

Java 8, 33 bytes

()->Integer.parseInt("bbc",'\r');
\$\endgroup\$
0
3
\$\begingroup\$

EXCEL: 148 bytes

=POWER(ROW()+ROW(),(ROW()+ROW()+ROW())*(ROW()+ROW()+ROW())+ROW()+ROW())-(POWER(ROW()+ROW(),ROW()+ROW()+ROW())*(ROW()+ROW()+ROW()+ROW())+ROW())-ROW()

only works in A1.

\$\endgroup\$
2
  • \$\begingroup\$ 1. It works anywhere in row 1. 2. Use the ^ operator instead. 3. You can also save a few using row 2 instead and a little algebra: =ROW()^((ROW()+ROW()/ROW())^ROW()+ROW())-ROW()-ROW()^(ROW()+ROW()+ROW()/ROW(. But then again, you can also save some by going all the way to Row 2014 too. \$\endgroup\$ Jul 10, 2020 at 12:23
  • \$\begingroup\$ Of course, concatenation is also an option. \$\endgroup\$ Jul 10, 2020 at 12:28
3
\$\begingroup\$

Sinclair ZX81 15 bytes 10 bytes

 PRINT CODE "=";CODE ":"

As the ZX81 has a non-ASCII compatible character set, the character code for = is 20 and for : it is 14 - simples.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ You've used a 1 in your answer. \$\endgroup\$ Apr 2, 2017 at 1:09
  • \$\begingroup\$ There is no way around making a ZX81 BASIC program without using line numbers. You may take out the line number and run it in direct mode if you wish. \$\endgroup\$ Apr 2, 2017 at 6:27
  • \$\begingroup\$ This is perhaps another reason why retrocomputing @ Stack Exchange should allow one-liners and code-golf therem, but apparently this would not constitute retro computing. Or something. \$\endgroup\$ Apr 2, 2017 at 6:30
  • \$\begingroup\$ Correction on my last comment: there not therem. \$\endgroup\$ Apr 2, 2017 at 7:24
3
\$\begingroup\$

Racket, 18 bytes

(~a(+ #xa #xa)#xe)
\$\endgroup\$
3
\$\begingroup\$

Clojure, 9 bytes

Inspired by the Matlab answer, converts char \u075e to an int:

(int \ߞ)
\$\endgroup\$
3
\$\begingroup\$

LiveScript, 18 bytes

The temporary solution

new Date!.getYear!

Unicode

\ߞ .charCodeAt!

Over Excitement

x=!Happy
Happy = -> console.log it
New = -> +it
Year = ->++x and Year
Year.valueOf = -> x

Happy New Year!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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\$ @GlitchMr, that's where the name came from :-) \$\endgroup\$
    – Brigand
    Jan 2, 2014 at 20:06
  • \$\begingroup\$ Only the "Unicode" solution is valid. The "temporary" solution violates the rule "... independently of any external variables such as the date or time" \$\endgroup\$ Sep 6, 2019 at 2:25
  • \$\begingroup\$ ... and the "Over Excitement" solution is not a serious contender, \$\endgroup\$ Sep 6, 2019 at 2:35
3
\$\begingroup\$

JSFuck, 1267 bytes

In Javascript, here is the alert(2014) ! (Try in browser Console).

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+[!+[]+!+[]]+[+[]]+[+!+[]]+[!+[]+!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()

This sample uses only six different characters to write and execute code. This was generated by https://github.com/aemkei/jsfuck.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Even though it's the longest answer rather than the shortest, +1 for JSFuck. \$\endgroup\$
    – Joe Z.
    Jan 1, 2014 at 21:04
3
\$\begingroup\$

Haskell, 69 bytes

How do you get a number without using any digits in the source? Lots of people had already done it with characters or strings, so I decided to use pi, predefined in most languages. From pi, you can get the numbers 3 and 4 easily using the ceiling and floor functions. Then you can use some combination of addition, subtraction, multiplication, and maybe division to get 2014. Just by experimenting around, it would be easy to figure out a function that takes in 3 and 4 and returns 2014 (such as 4^4 * 4 + 3^3*3^3 + 4*(3^4) - 4*4*4 + 4 - 3 = 2014). This one's 70 characters:

main=print$(\x y->y^y*y+x^x*x^x+y*x^y-y*y*y+y-x)(floor pi)$ceiling pi

Now, that's fine, but writing a function like that isn't much different than just repeatedly writing floor(pi) and ceiling(pi). Is it doable with only one pi? Well, in Haskell, functions can be treated as Monads with an instance defined in Control.Monad.Instances:

instance Monad ((->) r) where
        return = const
        f >>= k = \ r -> k (f r) r

So you can use the bind function to pass one value into two different functions: g (f x) (h x) can be rewritten f >>= flip (g.h). id >>= f can be used to pass the one value twice into the same function: id >>= (^) for example is a function that returns x to the x power. The resulting program at 207 characters is more obfuscated than golfed, but it was fun to write:

import Control.Monad.Instances
main=print.((id>>=(^)>>=flip((+).(id>>=(+)>>=flip((+).(id>>=(-)>>=flip((+).(id>>=div))))))).floor>>=flip((-).(id>>=(^)>>=flip((*).(round.sqrt.fromInteger>>=(*)))).ceiling))$pi
\$\endgroup\$
3
\$\begingroup\$

VB.NET, 59 bytes

MsgBox(((Asc(vbTab) + Asc(vbTab)) & Asc("~")) / Asc(vbTab))

takes the ascii values of a Tab twice (18) concats the ascii value of "~" (126), giving "18126" and then divides the lot by ascii of a Tab (9) = 2014

Alternatively, you can do

MsgBox Asc("j") * vbKeyPause

i.e. ascii of "j" (106) * value of the constant vbKeyPause (19), for a total of 28 characters (less than half the original).

\$\endgroup\$
3
  • \$\begingroup\$ The exact same code works for VB6 too. \$\endgroup\$
    – Rob
    Jan 4, 2014 at 0:06
  • \$\begingroup\$ user14566 suggested this edit: 27 bytes: MsgBox(Asc("") & Asc("")) =20 =14 \$\endgroup\$
    – Justin
    Jan 13, 2014 at 7:05
  • 2
    \$\begingroup\$ You can run this in the immediate window of VBA as ?Asc("j")*vbKeyPause, which shortens it up a bit. \$\endgroup\$
    – Gaffi
    Mar 5, 2014 at 16:46
3
\$\begingroup\$

R, 39 31 bytes:

x=T+T;x^(x*x*x+x)*x-x^(x*x)*x-x

R, also 39 31 bytes:

x=T+T;z=x*x;x^(z*x+x)*x-x^z*x-x

Thanks Scrooble!

More entertaining version: 46 bytes

z=pi;x=z*z;y=exp;j=z/y(z);floor(y(x)/(x-j-j))

Not especially efficient, but I had a lot of fun messing around with this. I'm sure there's a shorter way using just those two numbers

Long-form, subbing in the variables: floor(exp(pi*pi)/((pi*pi) - pi/exp(pi) - pi/exp(pi))

In real-person numbers: floor(19333.69 / (9.869604 - 0.1357605 - 0.1357605)) = floor(2014.328)

\$\endgroup\$
3
3
\$\begingroup\$

Julia 0.6, 9 bytes

Int('ߞ')

Try it online!

Just for completeness' sake. Here's 2018 (same trick, different character):

Int('ߢ')

Try it online!

And just for fun, here's a function using bit shifting and arithmetic instead of using character codepoints (depends on this being Julia version 0.6, which seems an appropriately golf-y hack):

Julia 0.6, 47 bytes

(l=VERSION.minor,o=true)->o<<(l+l-o)-o<<~-l-o-o

Try it online!

Here, o=true evaluates as 1 during arithmetic. VERSION is an inbuilt constant containing the current Julia version, and VERSION.minor is 6 in this case. We left shift 1 by 6+6-1=11, giving 2048, then subtract 1<<(6-1)=32 and 1 and 1 from it, to give 2014.

2018 version would be:

(l=VERSION.minor,o=true)->o<<(l+l-o)-o<<~-l+o+o
\$\endgroup\$
1
  • \$\begingroup\$ -1 byte : '߾'-' ' \$\endgroup\$
    – MarcMush
    Feb 23, 2021 at 13:06
3
\$\begingroup\$

MathGolf, 2 bytes

ID

Try it online!

Explanation

I   Pushes 20
 D  Pushes 14

The stack is printed in full on termination.

\$\endgroup\$
3
\$\begingroup\$

Keg, 2 bytes

ߞ

Keg auto pushes any characters that aren't instructions to the stack, and ߞ has a unicode value of 2014, which then gets printed.

Try it Online!

\$\endgroup\$
3
\$\begingroup\$

Raku (previously Perl6)

Raku interpret Unicode numbers as usual numbers, so:

In REPL – 7 bytes (3 chars):

⑳~⑭

Without REPL – 11 bytes (7 chars):

say ⑳~⑭

you can run it as rakudo -e "say ⑳~⑭"

\$\endgroup\$
3
\$\begingroup\$

Hexagony, 3 bytes

ߞ!

Try it online!

Or if you prefer code that terminates, here's 4 bytes:

ߞ!@
\$\endgroup\$
3
\$\begingroup\$

APOL, 38 bytes

-(⒏ l(*("eeeeeeeeeeeeeeeee" l("ee"))))

⒏ is a built-in constant that equals 2048, which is only 34 off from 2014. I use the length function to take the length of a 17-character string multiplied by 2 (which is shorter than a 34-character string) and implicitly print the result.

\$\endgroup\$
3
\$\begingroup\$

Quetzalcoatl, 11 4 5 bytes

::ord('ߞ')

The box should be replaced by Unicode character 2014.

Edit

This is for an old version of Quetzalcoatl. New version:

'ߞ'O
\$\endgroup\$
2
  • 1
    \$\begingroup\$ There is no ASCII character 2014... it has to be Unicode to go that high. \$\endgroup\$
    – mbomb007
    Mar 4, 2016 at 19:40
  • 1
    \$\begingroup\$ I'm not aware of any encoding in which ߞ would be a single byte. \$\endgroup\$
    – Dennis
    Apr 8, 2016 at 17:21
3
\$\begingroup\$

Fig, 4 bytes (UTF-8)

C/ߞ

Try it online!

Char casting, as most others.

\$\endgroup\$
3
\$\begingroup\$

Clojure (177 49 characters)

EDIT

Just tripped over this question again and realized there's a much better way to approach this:

(Integer.(apply str(map count["AA""""A""AAAA"])))

which cuts the length down by quite a bit.

How it works:

  1. (map count ["AA" "" "A" "AAAA"]) returns (2 0 1 4), which is a list containing the lengths of each of the strings in the argument vector.
  2. (apply str (...)) converts the elements of the list (2 0 1 4) into the string "2014".
  3. (Integer. (...)) converts the string from #2 ("2014") into the integer value 2014.
  4. This snippet returns the value 2014.

Original

In the true Lisp-ish spirit that "too many parentheses are never enough" I present:

(Integer. (clojure.string/join [(+ (second (range))  (second (range))) (first (range)) (second (range)) (+ (second (range)) (second (range)) (second (range)) (second (range)))]))

How it works:
The function range produces a lazy sequence of numbers. If no starting point and ending point are specified the range starts at zero and extends infinitely in the positive direction; however, because it's a lazy sequence the numbers are not produced until needed. Thus, applying the first function to the result of the range function without arguments produces the value 0, which is the first element in the sequence 0 to positive infinity. Applying the function second to such a range produces the value 1. From there it's a simple matter of producing enough 1's and summing them up to get 2 and 4, then converting them (implicitly) into strings to join then together, then converting the resulting string back to an integer. (I find it amusing that this is actually longer than some of the Brainf*ck answers - and to add to the horror, it's also legible :-).

Share and enjoy.

:-)

\$\endgroup\$
2
  • \$\begingroup\$ I suppose that you don't need to convert back to integer, instead add an output function. \$\endgroup\$ Jan 5, 2014 at 18:15
  • \$\begingroup\$ Do you need all that whitespace? \$\endgroup\$
    – cat
    Apr 18, 2016 at 2:38
3
\$\begingroup\$

Python 3, 27 bytes

I went through the effort of writing this script:

def to_base(n: int, b: int) -> str | None:
    if not 1 < b < 37:
        raise "Impossible base, try using a base between 1 and 37 (beginning and end not included)"

    if n == 0:
        return '0'

    possible_digs = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    res = []

    while n > 0:
        res += possible_digs[n % b]
        n //= b
    
    return ''.join(reversed(res))


def to_base_letters_only(n: int) -> str:
    bases_found = []
    for b in range(11, 37):
        c_n = to_base(n, b)
        digs_l_10 = False

        for d in c_n:
            if d in "0123456789":
                digs_l_10 = True
                break

        if not digs_l_10:
            bases_found.append([c_n, b])
    
    print(bases_found)

    if bases_found == []:
        return "No conversion found"
    return f"Conversion found: {(min_base := min(bases_found, key=lambda c: len(c[0])))[0]} in base {min_base[1]}"

print(to_base_letters_only(2014))

Which found BBC in base 13, which is 2014, without using arabic numerals.

So, my answer is this:

print(int("BBC",ord("\r")))

Try it online!

\r is Unicode 13.

Fun fact: This answer is 1 byte behind the Python 2 answer, because of print needing parentheses.

That script can also be used to find solutions for other numbers.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Normally we put the code first and the explanation afterwards \$\endgroup\$
    – mousetail
    Jan 3, 2023 at 14:32
  • \$\begingroup\$ You could save a byte by switching to Python 2: print int("BBC",ord("\r")) \$\endgroup\$ Jan 3, 2023 at 14:35
  • \$\begingroup\$ I already pointed out that. \$\endgroup\$
    – Joao-3
    Jan 3, 2023 at 14:57
2
\$\begingroup\$

PHP (21 chars)

<?=ord('').ord(''); //These are not empty strings ;)

If you don't believe it, see the proof.

\$\endgroup\$
3
  • \$\begingroup\$ That looks like 19 characters to me. \$\endgroup\$
    – Joe Z.
    Jan 2, 2014 at 15:06
  • 1
    \$\begingroup\$ (Oh wait, nonprintables.) \$\endgroup\$
    – Joe Z.
    Jan 2, 2014 at 15:07
  • 1
    \$\begingroup\$ If it contains non-printables, you should provide a hex dump or list them. \$\endgroup\$
    – mbomb007
    Mar 4, 2016 at 20:06
2
\$\begingroup\$

Python 51

Using true = 1 and false = 0

t=True
print str(t+t)+str(t-t)+str(+t)+str(t+t+t+t)
\$\endgroup\$
2
  • \$\begingroup\$ clever. 40 chars in PHP: $t=true;echo $t+$t.$t-$t.$t.$t+$t+$t+$t; \$\endgroup\$
    – zamnuts
    Jan 5, 2014 at 10:08
  • \$\begingroup\$ Damn just wrote that while reading the answers well done, \$\endgroup\$
    – Noelkd
    Jan 5, 2014 at 10:37
2
\$\begingroup\$

Python, 30 chars

s=int('RZ',ord('$'));print s+s

2014 => 2 * 1007 => RZ in base 36 => ascii code for $ character

In interpreted mode, without the print statement it is 24 chars:

s=int('RZ',ord('$'));s+s
\$\endgroup\$
2
\$\begingroup\$

Fortran: (43 27)

print*,z'FBC'/len('hi');end

Thanks to Hristo Iliev, the above is about 40% smaller! z'FBC' returns the decimal form of that hex value (which is 4028), len returns the length of hi (i.e.,2).


Original answer:

print*,ichar(',')*ichar(',')+ichar('N');end

Converts the string , and N to ASCII values: 44 & 78 respectively: 44**2 + 78 = 1936 + 78 = 2014.

\$\endgroup\$
2
  • \$\begingroup\$ Shorter version using hexadecimal literals: print*,z'FBC'/len('hi');end. \$\endgroup\$ Jan 8, 2014 at 12:31
  • \$\begingroup\$ @HristoIliev: Totally forgot about printing hex via z! Thanks a bunch! \$\endgroup\$
    – Kyle Kanos
    Jan 8, 2014 at 14:51
2
\$\begingroup\$

Bash, 29 bytes

Bash without using external programs:

echo $((x=++y+y))$?$y$((x+x))
\$\endgroup\$
1
  • \$\begingroup\$ Reduce to 25 bytes by using: echo $[y=++x+x]$?$x$[y+y]. \$\endgroup\$
    – user92894
    Aug 30, 2019 at 14:50
1 2 3
4
5
11

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