# Hack into a Lottery

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!

• predefined values. pfft – Matthew Roh Feb 21 '17 at 12:29
• can output be a hexadecimal number? – user902383 Feb 21 '17 at 13:25
• @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. – colsw Feb 21 '17 at 14:16
• I love the story lol. More challenges need a backstory like this – Cruncher Feb 22 '17 at 14:40
• So now that there are many solutions to choose from, was the gambling site a fraud? – Tominator Feb 23 '17 at 10:32

# Beeswax, 3 bytes

_M{


Explanation:

_   # Create a bee going horizontally across the line, reading the code
M  # Decrement the bee's counter, which starts at 0.
# This will set the counter to 2^64-1, because as bees don't have a concept of
# negative numbers, all values that are negative are translated to 2^64-n,
# and in this case, n = -1, as we are calculating 0 - 1.
{ # Print the value


Try it online!

This language is perfect for this challenge.

Here is an extract from the Esolang page on Beeswax:

As everyone knows, bees don’t have a concept of negative numbers, but they discovered that they can use the most significant bit of an address to get around that. Thus, coordinates relative to a bee’s position are realized by the two’s complements of the coordinates. This way, half of the 64-bit address space is available for local addressing without wraparound in each direction.

The maximum positive 64-bit two’s complement address is 9223372036854775807 or 0x7fffffffffffffff in 64 bit hex. All values from 0 up to this value translate identically to the same 64 bit value. All values n in the opposite (negative) direction translate to 2^64-n. For example: n=-1 is addressed by 18446744073709551615. n=-9223372036854775808 is addressed by 9223372036854775808.

This is basically unsigned longs.

EDIT: I'm still expecting Dennis to outgolf me with a 2-byte solution.

• You don't need to print it if the form will return the value. See other answers. – MatthewRock Mar 24 '17 at 14:28

# C, 26 bytes

main(){printf("%lu",~0l);}


Prints a unsigned long value.

Requires the size of long to be 64 bits.

• Nice one. Pretty much the same in Perl: print~0. – Dada Feb 21 '17 at 11:42
• ~0l should work. – Christoph Feb 21 '17 at 12:51
• @AnixPasBesoin it's a lowercase 'L' :) – Quentin Feb 22 '17 at 11:03
• You're assuming sizeof(long) * CHAR_BIT == 64. A reasonable assumption for golf, but worth pointing out. – Ray Feb 23 '17 at 3:11
• @Chris it's the bitwise not operator. – Ven Feb 23 '17 at 15:45

## 64-bit SBCL Common Lisp, 18 bytes

most-positive-word

Most positive word on 64-bit compiler is 64uint. It's something.

• Best syntax :)) – seshoumara Feb 21 '17 at 14:58
• Makes me very happy – Stan Strum Sep 12 '17 at 20:42

## CJam (4 bytes)

GG#(


Online demo

This calculates 1616 - 1 using builtin G for 16 and the decrement operator (.

• Definitely GG! ;) – WasteD Feb 21 '17 at 13:31
• gg, Peter, gg.. – cascading-style Feb 23 '17 at 2:20

# Python3 REPL, 12 bytes

In REPL: ~-(~-3<<9*7)

Outside of REPL: print~-(~-3<<9*7) <--> Python2!

Here's another one at 17 bytes: ~-(~-3<<ord("?")).

## Explanation

Nothing super fancy. Here's it broken down:

~-           | Subtract 1 from the next value.
(          |
~-3       | Subtract 1 from 3, resulting in 2
<<     | Binary shift 2's digits to left,
9*7  | by 9*7 (63).
) | The value inside the parentheses is now 2**64.


The resulting expression is roughly (but not quite) ~-(2<<63) -> (2**64)-1. I use the tadpole operator twice here. A golfing tip about it is here.

There is also sys.maxint in Python2 which can be used, but I won't be looking at that.

• Why does this code look like a cat that ate another cat? – OldBunny2800 Feb 27 '17 at 20:19
• @OldBunny2800 Is the ~-(~ part the eyes of the first cat? I can't see the second cat well... – Yytsi Sep 15 '17 at 10:29

# bc, 15 13 bytes

Saved 2 bytes thanks to manatwork.

(a=9+7)^a-3/3


Nothing fancy, just (16^16)-1.

• Welcome to PPCG! – ETHproductions Feb 21 '17 at 15:37
• (a=9+7)^a-3/3 – manatwork Feb 23 '17 at 8:34
• Thanks I was originally doing something like that in bash before I realised my answer was better as pure bc. – Richard Feb 23 '17 at 9:50

## dc, 7 bytes

I think it's allowed for stack based languages to leave the answer on the top cell of the stack, similar to a return value for functions. If explicit printing is needed, add p at the end of the code.

AZ5E^z-


Try it online!

It computes (2 64 - 1) using several tricks:

• 2 is given as the number of digits (Z) found in integer 10 (A)
• 64 is given as 5E. By default dc uses 10 as the input radix. Even so, it can accept numbers in hexadecimal notation, but they will be converted differently than you'd expect. Example: (5E)default = (5E)(input radix = 10) = (5 * 10 1) + (14(E) * 10 0) = 50 + 14 = 64

• 1 is given as the stack's depth (z), since only (2 64) was present then

### Alternative story:

However it is now that you notice some number keys don't seem to type into the remote console correctly. You take a deep breath and start testing each numerical key. It is worse than you thought! Not a single one works, and you're left with the task to produce your desired integer by using only letters and symbols.

Solution in dc: computing (16 16 - 1), still 7 bytes!

Fz+d^z-          # push 15, push 1, add, duplicate, exponentiate, push 1, subtract


Try it online!

• Great alternative story – cascading-style Feb 23 '17 at 2:22

# 05AB1E, 4 bytes

žJn<


Explanation:

žJ   # Push 4294967296
n  # Squared
< # Decreased by one


Finally! A chance to use 05AB1E's builtins for powers of two!

Try it online!

žxo<


Explanation:

  o  # 2 to the power of
žx   # 64
< # Decreased by one


Try it online!

(if anyone is wondering, this question is older than all the other 4-byte answers)

• I feel like there's a shorter solution along the lines of 64o< but I haven't found it yet. Something like '@Ço< with a creative 64 push... If you manage to push 64 with 1 byte, you can get 3 is the point I'm trying to make. – Magic Octopus Urn Feb 23 '17 at 19:51

# Jelly, 4 bytes

⁴*’


Try it online!

Explanation

⁴     # 16
*    # exponentiate
’  # decrement


# MATLAB / Octave, 5 bytes

@Sanchises posted an excellent MATLAB answer, however this one is a considerably different approach, so I'll post it anyway:

tic/0


In MATLAB, tic returns the number of milliseconds past since the program was opened. Crucially the value it returns is a uint64 type. This gets away from having to cast a number to uint64 from MATLABs default type of double.

Any number divided by 0 in MATLAB is considered as infinity which for non-floating point types, MATLAB represents this as the maximum integer value for that type.

This also works with Octave though depending on which interpreter you use it may spit out a "division by zero" warning as well. You can try the code online here though as I say you get a /0 warning that doesn't appear in MATLAB.

• Really clever approach, nice one. – colsw Feb 26 '17 at 15:37
• I'm only seeing this answer now. Very clever! (of course, it does not work if you execute this on a very fast computer such that tic==0 at startup 😉) – Sanchises Jul 23 '18 at 7:32

# bc, 18, 16 bytes

• Saved 2 bytes, thx @MrScapegrace
(9-7)^(55+9)-3/3

• can you use something like -3/3 to get -1? – Mr Scapegrace Feb 21 '17 at 15:32
• @MrScapegrace, yep that's a nice idea, thank you ! – zeppelin Feb 21 '17 at 15:34
• @boboquack 55+9 = 64, not 63! – JakeSteam Feb 22 '17 at 10:54

# Java 8, 30 bytes

()->Long.toUnsignedString(~0L)


Test online

• Missing java "boilerplate" and system.out.print part – Viktor Mellgren Feb 21 '17 at 14:08
• @ViktorMellgren This declares a lambda expression, which is perfectly fine. – Sanchises Feb 21 '17 at 14:30
• This requires Java 8 – mbomb007 Feb 21 '17 at 14:43
• Yes java 8 and up, no more boilerplate! Fear codegolfers! Java is a real contester now. This is the time you all were so scared about, all your codegolfing language are for nothing! Oh wait still 30 bytes,... hides – dwana Feb 21 '17 at 15:00
• Surely the "shorter solution" uses the illegal characters 1846. – Neil Feb 21 '17 at 22:40

### PHP, 16 bytes

This is much like the answer from Ven: https://codegolf.stackexchange.com/a/110751/38505

printf("%u",~0);


https://repl.it/Frcy/0

For this to work, you need to be in a 64-bit architecture. This is because ~0 is -1, which is 111111111111111111111111111111111111111111111111111111111111‌​1111 in binary, in 64 bits, compared to 11111111111111111111111111111111 in 32-bits, and the numbers are plataform-dependent - Ismael Miguel

• Lol. This works in bash too: printf %u $[~0]. – manatwork Feb 21 '17 at 14:55 • Aha, nice @manatwork – ʰᵈˑ Feb 21 '17 at 14:58 • This is architecture-dependent, it doesn't work on i386. – pts Feb 23 '17 at 13:54 • @pts Obviously! i386 is 16/32-bits. PHP is very picky about that. For this to work, you need to be in a 64-bit architecture. This is because ~0 is -1, which is 1111111111111111111111111111111111111111111111111111111111111111 in binary, in 64 bits, compared to 11111111111111111111111111111111 in 32-bits, and the numbers are plataform-dependent. – Ismael Miguel Feb 23 '17 at 14:36 • @ʰᵈˑYou're welcome. I must admit that I slacked a bit. I've copy-pasted 32 1's. If you want, you can fix your grammar a bit on your answer. – Ismael Miguel Feb 23 '17 at 14:42 ## MATLAB / Octave, 22 bytes eye(['~rw}?='-9 ''])/0  Try it online! eye is used to create a unit matrix (matrix with 1  on the diagonal, zero otherwise). Without arguments, this creates a 1x1 unit matrix, or in other words, just a 1. It takes an optional argument, which is the data type ('class' in MATLAB terminology) of the created matrix. We thus ask for a 1 of class uint64 , and divide it by zero which results in Inf in MATLAB, which gets clipped at intmax('uint64'). The vector ['~rw}?='-9 ''] evaluates to 'uint64'. Concatenating an empty char to a vector is 1 byte shorter than using char('~rw}?='-9). Reasoning towards this answer: the built-in intmax sadly evaluates to the maximum of a 32 bit signed integer. The obvious next option is uint64(), which contains the forbidden characters. The alternative is to use a function that takes a string as a data type. Obvious candidates are intmax and cast, but alternatives include zeros, ones and eye. eye(['~rw}?='-9 ''])/0 % Winning version! 22 bytes. intmax(['~rw}?='-9 '']) % Obvious candidate. 23 bytes. 1/zeros(['~rw}?='-9 '']) % 24 bytes cast(Inf,['~rw}?='-9 '']) % 25 bytes. Also an obvious candidate, but actually very long.  Note: MATLAB is installed by default on virtually all dodgy gambling sites. ## JavaScript, 393833 32 bytes alert(0xafebff0+'737095'+0xc99f)  Edit: Saved 5 bytes thanks to @Arnauld. • Remove alert as this can be run in a console. – Alexis Tyler Feb 23 '17 at 14:14 # BF, 108 bytes -[----->+<]>--.+++++++.----..++.+.---..----.+++++++.----.++++.-------.+++++++++.----..----.+++++.-----.++++.  If each command is considered as 3 bits, this is potentially 41 bytes. • Each command is one byte. Not 3 bits. – mbomb007 Feb 21 '17 at 14:45 • Well yes, that's why I put it as 108 bytes... – Timtech Feb 21 '17 at 15:32 • Yeah, but you said "this is potentially 41 bytes", which it's not. – mbomb007 Feb 21 '17 at 15:56 • An interpreter could be made to interpret 3-bit groups as one of eight commands +-<>[]., – Timtech Feb 21 '17 at 15:56 • That already exists. It's called esolangs.org/wiki/Binaryfuck – mbomb007 Feb 21 '17 at 15:57 # Retina, 28 27 bytes Saved 1 byte thanks to Kritixi Lithos  bieegheeahdhajffbgbf Tld  Try it online! Explanation  bieegheeahdhajffbgbf Replaces the non-existent/empty input with this string. This particular string was generated by the "inverse" of this program. It encodes a through j as 0 through 9, respectively. Tld  This is a Transliteration stage. The l and d are character sets used for transliteration. l represents the lowercase alphabet, d is all digits. So, it maps abcdefghij back to 0123456789. # PowerShell, 29 14 bytes 0xC000PB/3-3/3  Try it online! Thanks to @n0rd for essentially golfing this in half. This leverages the inbuilt unary PB operator that basically functions as "multiply the preceding number by 1125899906842624" (i.e., how many bytes are in a pebibyte). That's coupled with the hex 0xC000, or 49152, so 49152 pebibytes. We divide that by 3, yielding 18446744073709551616, and subtract 3/3 to get the final value. • "0x$(7-3)000PB-9/9"|iex – n0rd Feb 23 '17 at 6:41
• 0xC000PB/3-3/3 – n0rd Feb 23 '17 at 6:46
• @n0rd Oh, that's dang clever, using PB like that. Thanks! – AdmBorkBork Feb 23 '17 at 13:24
• @n0rd pretty impressive, welcome to PPCG! – colsw Feb 23 '17 at 13:37

# JavaScript (ES6), 50 bytes

[...'䠎ᴐIF╏ɧ'].map(s=>s.charCodeAt()).join

• You can change the characters to '䠎ᴐIF╏ɧ' and remove the -27 – powelles Feb 22 '17 at 19:25
• @jdp Nice one, thanks :) – George Reith Feb 23 '17 at 14:20

# C++, 46 bytes.

int m(){std::cout<<unsigned long long(5+3-9);}


First time ever doing a code golf, but I'm fairly happy with myself. Will happily take any critique/suggestions :)

# Brain-Flak, 64, 62, 58, 54 bytes

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


Try it online!

[Try it online!]

Four bytes saved thanks to @Riley!

Explanation:

#Push a 64
(((((()()()()){}){}){}){})

#While true
{

#Pop the top of the stack. We'll store this value for later, but first
({}

#Before pushing the value
<

#Push (N + 1) * 2 - 1
# (where N is the number underneath, originally 0)
(({}()){}[()])

>

#And push the TOS minus one back on
[()])

#endwhile
}

#Pop the zero left over
{}

#And decrement the number underneath
({}[()])


For the record, I tried pushing 32 and quadrupling, but it's the same byte count.

• You can save 4 bytes by using one of the ()s from 64 to push the 1: ((((((())()()()){}){}){}){}) – Riley Feb 21 '17 at 22:18
• @Riley Aha, of course! Thanks – James Feb 21 '17 at 22:21
• – Leaky Nun Apr 30 '17 at 16:03
• – Leaky Nun Apr 30 '17 at 16:05
• Um, can't you just do N*2+1 instead of (N+1)*2-1? – Jo King Jul 23 '18 at 0:06

# C# 6, 31 bytes

()=>System.Console.Write(~0UL);


Pretty much the same as Java.

# C# 5, 56 bytes

class P{static void Main(){System.Console.Write(~0UL);}}

• The C# 6 answer is only an anonymous action, which are also present in C# 5. – TheLethalCoder Feb 21 '17 at 16:03
• Also the challenge only asks you to output the number so you could compile to a Func<ulong> as: ()=>~0UL; – TheLethalCoder Feb 21 '17 at 16:05
• It also doesn't say that you can't use any input so you could compile to a Func<int, ulong> to save a byte: _=>~0UL; and I think it would still be valid. – TheLethalCoder Feb 21 '17 at 16:06

# Forth (gforth), 119 7 bytes

true U.


Try it online

true is the same as -1. U. prints a number as an unsigned integer.

This works on TIO, possibly because it has a 64-bit architecture? I'm not sure. If I run -1 U. on repl.it, for example, I get 2**32-1. If repl.it supported double-length integers, outputting them would use UD. instead.

• You can probably reduce this to -3 3 / U. – zeppelin Feb 21 '17 at 16:23
• Or, even better: true U. (which also rhythms nicely) – zeppelin Feb 21 '17 at 16:25
• Oh, I forget about true, because I'm so used to using 0 and 1. Thanks. – mbomb007 Feb 21 '17 at 16:27

## Python3 REPL, 11 bytes

~0^~0>>~077


### How it works

• ~0 is -1 (two's complement, an infinite sequence of '1's)
• 077 is 63 in octal, so ~077 is -64
• Shift right with negative parameter is a shift to the left
• Putting all together, -1 xor (-1 << 64) is the number we are looking for

# Swift, 8 bytes

UInt.max


### outside playground / repl - 15 bytes

print(UInt.max)


# x64 Assembly, 7 bytes

hex (assembled): 4831C048FFC8C3

disassembled, commented:
 XOR RAX,RAX ;Zero the value of 64 bit register RAX DEC RAX ;Decrement the value of RAX RET ;Return this value

RAX is a 64 bit register, and is most often used to return integer arguments (eg, C). By decrementing 1, its value rolls over from 0 to... 2^64-1, which is exactly needed.
Though, the assembled binary contains ones and fours and eights, the assembly doesn't, but the assembled file is counted in assembly, so does it count? Ow, my head.
Also, output is return value in this case.

# Brain-Flak, 223 193 bytes

Includes +1 for -A
-30 thanks to DJMcMayhem

((((((((((((((((((((((((()()()){}){}()){}){}())[()()()()])[][]())[[]()()])[]))()()()())[[]()()])[][()])[()()()()])()()()())[(()()()){}()])()()()()))()()())[()])[()()]))()()()())[(()()()){}()])


Try it online!

This just pushed the ASCII values of and prints as characters.

For reference, it takes 338 bytes to generate the actual number using the Integer meta golfer.

((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()()()){}()){}){}()){}()){({}[()])}{}()){}()){}())){}{})){}{})()){}{})){}{})){}{})()){}{})){}{})){}{}){}){}())){}{}){}())()){}{})){}{}){}){}){}())()){}{})()){}{})){}{}){}())){}{})()){}{})){}{})){}{})){}{})()){}{})()){}{})){}{}){}())){}{}){}){}())()){}{})()){}{})){}{})


Try it Online!

# 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.suever.net

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

• It'd need to be YY5Z%ZD to force uint64 type, but I don't know why using 1 5Z% instead just works... – B. Mehta Feb 21 '17 at 14:12
• You can't use 8. – xnor Feb 21 '17 at 14:13
• @xnor Oops, fixed. – B. Mehta Feb 21 '17 at 14:16
• Can you add a demo link using either matl.suever.net or matl.tryitonline.net? – Suever Feb 21 '17 at 21:53
• @LuisMendo Ah, of course - I thought cast was used, but it makes sense if typecast is used. Thanks for clearing that up. – Sanchises Feb 24 '17 at 10:55

## 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

• Displays 2588673709551615 for me... – n0rd Feb 23 '17 at 19:11
• alert(0xafebff0+'7370955'+(3*59*73>>3)) works fine – n0rd Feb 23 '17 at 19:12
• I am leaving it as it is for the sake of keeping the method used instead of just copying someone else now. – fəˈnɛtɪk Feb 23 '17 at 19:20

# JavaScript, 50 bytes 47 bytes

parseInt(5%3+"7nq9nb9r7b",33+7-9)+btoa("×­y")

• Why do you append the answer to ''? – Marie Jul 23 '18 at 12:33
• @Marie it doesn't: repl.it/repls/SubstantialNoisyRectangle – Tymek Jul 23 '18 at 12:36
• You misunderstood. Why does your code start with ''+? Unless I am missing something, which is possible, you dont need that. – Marie Jul 23 '18 at 12:51
• ah, ok. I didn't read the requirements right. It can be "either a number, or a single string". Thank you – Tymek Jul 23 '18 at 12:54
• Lol, I didnt notice that but my actual point was that btoa returns a string so either way the result should be a string. – Marie Jul 23 '18 at 12:56