49
\$\begingroup\$

You've recently made an account on a dodgy gambling site, where for a fee of 25 dollars, they will pay you back a random amount between 0 and 50 dollars. After getting around 5 dollars twice, you decide to prove the site is a scam. After accessing their external firewall with the default password, you find your way onto their database server, and find where the values for the minimum and maximum amounts are held. You decide to plug 25 '9's in as the maximum value, but get an error message saying the maximum value must be of type 'uint64'. However it is now that you notice some number keys don't seem to type into the remote console correctly. The challenge appears before you almost as if typed up on a Q+A site.

using only the conveniently installed programs for testing and executing your particular language, output the maximum size of an unsigned 64-bit integer value, however almost everything except the programming tools are broken on this machine, leaving you without the use of the numbers 1,2,4,6,8 - in either source code or literals, you also notice that it seems to take an exponentially longer amount of time to execute the program for each additional piece of code, so you'd better keep it short if you want to get rich before the drawing!


The Challenge

  • Write a program which outputs 18446744073709551615, the maximum value of an unsigned 64-bit integer, as either a number, or a single string.

  • Your source code cannot contain any of the characters '1','2','4','6' or '8'

  • if your language does not have an unsigned 64-bit integer or equivalent, the output can be in string format or otherwise, but must be the above number.

  • this is so shortest code in each language wins!

\$\endgroup\$
8
  • 15
    \$\begingroup\$ predefined values. pfft \$\endgroup\$ Commented Feb 21, 2017 at 12:29
  • \$\begingroup\$ can output be a hexadecimal number? \$\endgroup\$
    – user902383
    Commented Feb 21, 2017 at 13:25
  • 1
    \$\begingroup\$ @user902383 must be in the exact format, feel free to parse it as a hex number, as long as the output is in normal decimal notation. \$\endgroup\$
    – colsw
    Commented Feb 21, 2017 at 14:16
  • 14
    \$\begingroup\$ I love the story lol. More challenges need a backstory like this \$\endgroup\$
    – Cruncher
    Commented Feb 22, 2017 at 14:40
  • 4
    \$\begingroup\$ So now that there are many solutions to choose from, was the gambling site a fraud? \$\endgroup\$
    – Tominator
    Commented Feb 23, 2017 at 10:32

90 Answers 90

3
\$\begingroup\$

JavaScript, 50 bytes 47 bytes

parseInt(5%3+"7nq9nb9r7b",33+7-9)+btoa("×­y")
\$\endgroup\$
5
  • \$\begingroup\$ Why do you append the answer to ''? \$\endgroup\$
    – Marie
    Commented Jul 23, 2018 at 12:33
  • \$\begingroup\$ @Marie it doesn't: repl.it/repls/SubstantialNoisyRectangle \$\endgroup\$
    – Tymek
    Commented Jul 23, 2018 at 12:36
  • \$\begingroup\$ You misunderstood. Why does your code start with ''+? Unless I am missing something, which is possible, you dont need that. \$\endgroup\$
    – Marie
    Commented Jul 23, 2018 at 12:51
  • \$\begingroup\$ ah, ok. I didn't read the requirements right. It can be "either a number, or a single string". Thank you \$\endgroup\$
    – Tymek
    Commented Jul 23, 2018 at 12:54
  • 1
    \$\begingroup\$ Lol, I didnt notice that but my actual point was that btoa returns a string so either way the result should be a string. \$\endgroup\$
    – Marie
    Commented Jul 23, 2018 at 12:56
3
\$\begingroup\$

MathGolf, 3 bytes

Port of the 05AB1E answer. But 1 byte shorter.

♦ó(

Try it online!

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

MATL, 8 bytes

l_5Z%EZD

This could probably be improved, but I'm not familiar with strings and types in MATL just yet.

Try it at matl.io

Explanation:

l       % push 1
_       % unary minus
5       % push 5, corresponds to type 'uint64'
Z%      % convert 1 to this type
E       % double
ZD      % display as a string
\$\endgroup\$
7
  • \$\begingroup\$ It'd need to be YY5Z%ZD to force uint64 type, but I don't know why using 1 5Z% instead just works... \$\endgroup\$
    – B. Mehta
    Commented Feb 21, 2017 at 14:12
  • \$\begingroup\$ You can't use 8. \$\endgroup\$
    – xnor
    Commented Feb 21, 2017 at 14:13
  • \$\begingroup\$ @xnor Oops, fixed. \$\endgroup\$
    – B. Mehta
    Commented Feb 21, 2017 at 14:16
  • \$\begingroup\$ Can you add a demo link using either matl.suever.net or matl.tryitonline.net? \$\endgroup\$
    – Suever
    Commented Feb 21, 2017 at 21:53
  • 1
    \$\begingroup\$ @LuisMendo Ah, of course - I thought cast was used, but it makes sense if typecast is used. Thanks for clearing that up. \$\endgroup\$
    – Sanchises
    Commented Feb 24, 2017 at 10:55
3
\$\begingroup\$

GolfScript, 16 14 12 9 7 bytes

9(.+.?(

Try it online!

9(.+.?(
     9( = 8
     .+ = +8 = 16
     .? = ^16 = 16^16
     (  = -1

Some alternative solutions (also 7B)

5(33(?(
7).+.?(
\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$ Commented Nov 7, 2022 at 16:08
2
\$\begingroup\$

Jelly, 7 bytes

3’*“@‘’

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Why does the TIO link have different code? \$\endgroup\$
    – Okx
    Commented Feb 21, 2017 at 11:57
  • \$\begingroup\$ @Okx Forgot to update the link, fixed :) \$\endgroup\$
    – Ven
    Commented Feb 21, 2017 at 11:59
  • \$\begingroup\$ I think you could do 3’ to get 2. \$\endgroup\$ Commented Feb 21, 2017 at 15:48
  • \$\begingroup\$ @ETHproductions thanks :P. \$\endgroup\$
    – Ven
    Commented Feb 21, 2017 at 15:58
2
\$\begingroup\$

Ruby, 16 12 bytes

p~0^~0>>~077

Prints out the number. In REPL mode this would be 11 bytes (without the 'p')

\$\endgroup\$
2
\$\begingroup\$

C++, 26 24 16 bytes

26 bytes: My first submit

main(){std::cout<<(~0UL);}

[EDIT]24 bytes: () is not necessary

main(){std::cout<<~0UL;}

[EDIT]16 bytes: without main(){}

std::cout<<~0UL;

Obviously, Every c++ program must have an entry point function.

So I think we should not count it as a part of the answer.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks, and i'm sorry for violate the rules. i'm totally new to this site xD \$\endgroup\$
    – Divcy
    Commented Feb 23, 2017 at 15:01
  • 1
    \$\begingroup\$ no worries - the site has a couple of things you'll need to get used to, but it's definitely a great way to waste time and have some fun, check out the questions guide and if you have any questions just make a post in the meta forums - best of luck. \$\endgroup\$
    – colsw
    Commented Feb 23, 2017 at 16:34
  • 3
    \$\begingroup\$ @ConnorLSW this is not the case, we go as far as allowing answers with exactly the same content as each other (currently at +24/-7). We absolutely encourage users to post answers in the same language as already posted in. \$\endgroup\$
    – Blue
    Commented Feb 23, 2017 at 21:42
2
\$\begingroup\$

Javascript 55 bytes

alert(""+(590300>>5)+(59530-3>>3)+7370955+(3*59*73>>3))

the code generates and then alerts the string 18446744073709551615 using bitwise operations

590300>>5 18446
59530-3>>3 7440
7370955
3*59*73>>3 1615

\$\endgroup\$
3
  • \$\begingroup\$ Displays 2588673709551615 for me... \$\endgroup\$
    – n0rd
    Commented Feb 23, 2017 at 19:11
  • \$\begingroup\$ alert(0xafebff0+'7370955'+(3*59*73>>3)) works fine \$\endgroup\$
    – n0rd
    Commented Feb 23, 2017 at 19:12
  • \$\begingroup\$ I am leaving it as it is for the sake of keeping the method used instead of just copying someone else now. \$\endgroup\$ Commented Feb 23, 2017 at 19:20
2
\$\begingroup\$

Mathematica 44 39 Bytes, No numbers

Well I could do the 22 Byte answer Print[(9+7)^(9+7)-3^0]

Here's an answer using addition to build up to the desired number with no numbers in the code:

f=Nest[#+#&,p=E/E,#]&;f@f@(f@p+f@f@p)-p

Saved 5 bytes thanks to @Martin-Ender

\$\endgroup\$
4
  • \$\begingroup\$ p=E/E and f@f[f@p+f@f@p] \$\endgroup\$ Commented Feb 23, 2017 at 14:44
  • \$\begingroup\$ Actually, it's shorter to define an operator ± instead of a function f and you can delay assigning p until the Nest is being called: ±x_:=Nest[#+#&,p=E/E,x];±±(±p+±±p)-p \$\endgroup\$ Commented Feb 23, 2017 at 14:55
  • \$\begingroup\$ Thanks for the tips. Incorporating the first two. The ± character eats up 2 bytes, so no savings by that measure, but it costs 3 extra bytes to define. \$\endgroup\$ Commented Feb 23, 2017 at 19:49
  • \$\begingroup\$ ± is a single byte in several single-byte code pages e.g. the Windows ANSI code page CP1252, which is actually the default encoding for source files on Windows installations. \$\endgroup\$ Commented Feb 23, 2017 at 21:06
2
\$\begingroup\$

TI-Basic, 14 11 bytes

int(e
Ans^Ans²³-1
  • Many commands in TI-Basic are single or two-byte tokens.

  • The superscript characters are different tokens, so they are allowed.

\$\endgroup\$
2
\$\begingroup\$

C#, 20 bytes

()=>ulong.MaxValue;
\$\endgroup\$
2
  • 1
    \$\begingroup\$ This is neither a full program nor a function / lambda and therefore invalid. \$\endgroup\$
    – corvus_192
    Commented Feb 21, 2017 at 21:27
  • 1
    \$\begingroup\$ Hello, welcome to the site! As Corvus_192 pointed out, this isn't a full program or function, so it is invalid. If you output this value somehow, the answer will be valid. (For example, print to the console, return from a function, etc.) I'm going to vote to delete this answer for now, but if you edit your answer to be valid, I will retract my vote, or vote to undelete it. You could also [flag] it for a moderator to undelete it. Thanks! \$\endgroup\$
    – DJMcMayhem
    Commented Feb 21, 2017 at 21:34
2
\$\begingroup\$

Pyth, 9 7 bytes

t^Jyh7J

Online interpreter link.

Uses Emigna's algorithm.

Thanks to Leaky Nun for digging this answer out so that I could -1 it.
-1 because I found yh7 which is shorter than +9 7.

yh7 seems to be the shortest way we can make 16 without using 12468.

\$\endgroup\$
4
  • \$\begingroup\$ I'm sure you know what you can golf down now. \$\endgroup\$
    – Leaky Nun
    Commented Apr 30, 2017 at 11:20
  • \$\begingroup\$ @LeakyNun The thing is that I can't use 12468, although this is an answer from when I was inexperienced. Let's see what we've got here... \$\endgroup\$ Commented Apr 30, 2017 at 13:41
  • \$\begingroup\$ It's the same as the previous answer from you wherein I commented. \$\endgroup\$
    – Leaky Nun
    Commented Apr 30, 2017 at 13:41
  • \$\begingroup\$ @LeakyNun I found something else too. Golfed. \$\endgroup\$ Commented Apr 30, 2017 at 13:46
2
\$\begingroup\$

Chip, 67 bytes + 3 bytes = 162 70 bytes

(+3 is for flag -w)

*Z~vZZZZvZvvZZZZvZZ-vZZvZZ-ZZvZZt
e*fad`c'`bac^^zba^^bc da^^cabca^c

Try it online!

Chip is a 2D language inspired by integrated circuits, input and output are broken down into individual bits which travel through gates and across wires.

Let's look at the ungolfed version:

*Z~-v-Z-Z-Z-Zv-Zvv-Z-Z-Z-Zvv-Zv-Zvv-Z-Zv-Zv-Zv-Z-Zv-Z-Zvt
e*f a d c c bc abc c c   abc ab abc   ad ac ac a bc a ac

The first portion has two components: *Z~ and e*f. *Z~ creates a 1-cycle pulse to kick off the circuit. e*f is equivalent to the value 0x30, which is the ASCII code for "0".

The remainder of the circuit has one portion for each ASCII digit of the output. For example:

-Zv-
 bc

The elements a, b, c, and d are the low four bits of output: a is 0x01, b is 0x02, and so on. In this sample, we have b and c, giving us 0x02 | 0x04 = 0x06. This combines with the code above to give us 0x30 | 0x06 = 0x36, which is the ASCII code for "6".

The Zs with nothing below them simply result in "0".

At the end, t causes the program to halt.


If instead you want the actual binary value instead, corresponding to eight 0xFF bytes, you can accomplish this in only 22 + 3 = 25 bytes:

a*ZZZZZZZt
dc
*eh
fg*b

The output of this can be verified by e.g. piping it into od -vtu8.

\$\endgroup\$
2
  • \$\begingroup\$ This is answer 111111 \$\endgroup\$
    – anna328p
    Commented Feb 24, 2017 at 0:16
  • \$\begingroup\$ @wat Oooo so it is :) \$\endgroup\$
    – Phlarx
    Commented Feb 24, 2017 at 15:45
2
\$\begingroup\$

MATL, 7 bytes

I3Z%WZD

Try it online!

Do a typecast on 3 (actual number doesn't matter much) to uint64, which reinterprets the bits of the default double precision float as an unsigned integer, giving a large value. Raise that to the power of 2, overflowing the range of uint64, which makes Matlab clamp it to the upper limit of 18446744073709551615.

\$\endgroup\$
2
\$\begingroup\$

brainfuck, 99 bytes

-->>->+>->>>+>->+>>+>->>>+>+>>>+>+[>+++[-<+++++>]<[->+++<]<++]>>+>>->>+>+>++>->>->>->>>>->>>+>[+.<]

Try it online!

Uses a ternary system for numbers between 0 and 8 (and a little cheat for the 9).

-, - = 0
-, 0 = 1
-, + = 2
0, - = 3
0, 0 = 4
0, + = 5
+, - = 6
+, 0 = 7
+, + = 8
+, ++ = 9
\$\endgroup\$
2
\$\begingroup\$

Stax, 5 bytes

üó|>b

Run and debug it

This is simply the packed version of the program 64|2v which means 2**64-1. Yes, boring.

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

Brain-Flak, 62 58 bytes

(()())((()()()){}){({}<({({})({}[()])}{})>[()])}{}({}[()])

Try it online!

This runs into a timeout, but here's the "source".

(()())                 init stack with 2
((()()()){}){          repeat 6 times
    (
        {}
        <({({})({}[()])}{})> square the value
        [()]           decrement loop counter
    )
}
{}                     pop 0
({}[()])               decrement value
                       implicitly print it

It calculates ((((((2^2)^2)^2)^2)^2)^2)-1 and prints it

\$\endgroup\$
2
\$\begingroup\$

JavaScript, 67 52 47 45 39 bytes

b=9+7;(b**b+'').substr(0,b)+btoa('×­y')
\$\endgroup\$
2
\$\begingroup\$

Python 2, 21 bytes

print~-(5-3)**(97-33)

Try it online!

5-3 = 2, 97-33 = 64, ~- to decrement.

\$\endgroup\$
2
\$\begingroup\$

Cascade, 12 bytes (UTF-8)

#
(
*
*
*
Ā

Try it online!

I can't think of a cleverer way to fold this up that wouldn't kill the squaring. Note that Ā has codepoint 256. Two characters can be shaved off by using 65536 instead, but it comes out to precisely the same byte count:

Cascade, 12 bytes

#
(
*
*
𐀀

Try it online!

\$\endgroup\$
2
\$\begingroup\$

C (clang), 26 18 16 bytes

f(){return~0UL;}

Try it online!

Saved 8 bytes from changing from printf to return. Saved 2 bytes by using the bitwise NOT from the C++ answer.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Your returned type is signed int \$\endgroup\$
    – l4m2
    Commented Dec 15, 2022 at 4:44
2
\$\begingroup\$

Julia 1.0, 17 15 bytes

print(~UInt(0))

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Bash, 27 bytes

printf %u $[57#OSiLrEickbS]

Try it online!

Uses pre-calculated base-57 string. Why base-57? Because anything larger would require one of the prohibited digits.

printf %u $[-3/3]
would also work for 17 bytes, but that’s been done...
\$\endgroup\$
3
  • \$\begingroup\$ Or use $[~0] for 15 bytes. \$\endgroup\$ Commented Nov 8, 2022 at 21:02
  • \$\begingroup\$ @GammaFunction, printf %u $[~0] is giving me a "syntax error: operand expected" on my bash. \$\endgroup\$
    – spuck
    Commented Nov 8, 2022 at 23:05
  • \$\begingroup\$ Ah, it must be a Bash 5 thing. My mistake, that would make it non-competing. \$\endgroup\$ Commented Nov 9, 2022 at 21:32
2
\$\begingroup\$

Nim, 14 bytes

echo high uint

Attempt This Online!

\$\endgroup\$
2
\$\begingroup\$

AWK, 39 bytes

{$0=(a+=++a)^(a*=a*=a*a);sub(".$",5)}5

Usage:

awk '{$0=(a+=++a)^(a*=a*=a*a);sub(".$",5)}5' <<< " "

Annoyingly AWK has trouble with integer math beyond 2^53 since it internally converts large integers to 64-bit doubles. Since 2^64 can be exactly represented as a double, its string representation should be exactly 18446744073709551616 (it is on my machine, anyway). Unfortunately, 2^64 - 1 == 2^64, so I could not simply decrement the value, hence the workaround via string substitution.

Byte-count includes 1 additional byte due to requiring at least 1 byte for input which could be ctrl-D

Try it online!

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

Japt, 17 bytes

GpG s r#È*A+PG+Fs

Try it online!

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

Vim, 41 bytes:

:im a <C-o><C-v><C-a>
i0a7a3a3a5a73a3a073709550a5a0a5

This uses the <C-a> command (increment) to get around the restriction of not using 1, 2, 4, 6, or 8. No TIO link since this doesn't seem to work in V, but it definitely works on vim locally.

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

MSSQL, 33 37 30 29 27 bytes

SELECT power(9.+7,9+7)-77*5

Bigint is too big, so I'm counting 2^64-1 manually. I'm not sure why, but power(2,64) gives 18446744073709552000, so I have to substract 385.

-2 bytes thanks to @ETHproductions

\$\endgroup\$
4
  • \$\begingroup\$ Source code can't contain 2. \$\endgroup\$ Commented Feb 21, 2017 at 15:31
  • \$\begingroup\$ @MichaelMcGriff fixed. \$\endgroup\$ Commented Feb 21, 2017 at 15:44
  • \$\begingroup\$ power(2,64) is probably converted from floating-point, and the conversion routines are probably limited by the 17-digit known precision of floating-point values i.e. they can't assume you want exactly 2^64, so they just give you a value which converts to the same floating-point value. \$\endgroup\$
    – Neil
    Commented Feb 21, 2017 at 22:47
  • \$\begingroup\$ @ETHproductions yes, thank you. \$\endgroup\$ Commented Feb 22, 2017 at 7:27
1
\$\begingroup\$

Cardinal 42 bytes

%+.+=tt.''..*."7"'.."07370955"0+.*t.0+.**.

Try it Online

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

J, 10 bytes

<:JSB^<:5x

JSB is a constant equal to 65536. <: is x - 1. 5x is 5 as an extended integer. ^ is exponentiation.

I spent a really long time working on this. Here are my other solutions:

<:JSB^<:5x
<:^~+:>:7x
<:^~*:<:5x
<:^~*:>:3x
<:^~+:<:9x
<:^~x:JCMPX
<:x:*:*:JSB
<:^~x:%:#a.
#.1x#~*:<:9
<:x:^~>.^^^0
<:x:^~>.^^*_
<:^~<:p:>:5x
<:^~-:x:JBOXED
<:x:^~>.^~^*_
<:x:^~>.^~^^~%_
<:%:*:^:5+:<:9x
<:x:+:+:9!:20''
<:x:^~*:+:+:*__
>:+:#.1x#~#.6#1
<:x:*:*:-:JCHAR2
<:*:*:*:*:+:<:9x
<:x:^~>.%:3 u:EAV
<:x:*:*:3!:0 s:''
<:x:^~>.^^*JCHAR4
<:JCHAR^x:+:JBOXED
<:x:^~>.^^*#dbhelp
<:x:^~>.^^*3 u:DEL
<:x:^~>.^^*#show'show'
<:x:dfh":(>:9)^x:%:#a.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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