title: I'm too cold, turn up the temperature

text:
# Question
Title: I'm too cold, turn up the temperature
This is my first golf contest.

**What you need to do**

Build me, in the shortest amount of bytes possible, my AC remote control system. My room is too cold right now, and I'm missing my remote.

Now, I don't want you literally building it or anything, just golf this:

A slow increment of temperature, starting at 40 degrees, and ending at exactly 72. The increment time must always be 500 millis per increment. It can wait another 500ms at the end. I would prefer it to stop however. The increment itself must go up by two each time, like my remote.

You should not clear the screen. You should have newlines.

**What should happen**

Example output (everything in parentheses shouldn't be outputted).

```
40
(wait 500 millis)
42
(wait 500 millis)
44
(..repeat until 72..)
72
(stop or wait 500ms)

```

**Keep in mind** This is my first golf, so I apologize if this is too hard to golf. :(

Best of luck, golfers!

# Answer
> 40 votes
# Minecraft 1.9.0+, ~~204~~ 162 bytes + ~~58~~ ~~36~~ ~~28~~ ~~24~~ 20 blocks = ~~262~~ ~~240~~ ~~232~~ ~~186~~ 182 blytes

This solution is golfed down, and it can't be seen whole in one, or even two screenshots. Uses two glitches and abuses another two features of the game

This solution uses the same principles as the one below, just a 4 blocks more compact design.

* Abuses the fact that Chain command blocks (green blocks) can't be powered by redstone, only by a singal from a impulse command block (orange).
* Abuses the fact pistons take 0.30 seconds to extend completely, and redstone needs only 0.10s to register a signal.
* Also abuses a twofold glitch to set the timer (TNT) off: the redstone next to the timer (TNT) gets not only powered, but also thinks the TNT is another redstone and powers it.
* On top of all these abuses, the signal shortener (thing under the TNT) is one-use, after it gets powered it changes shape, allowing to pass signal *through* it to the "incrementer" (topmost orange block)

A bit of explanation on the functionality of it's different parts can be seen in older solutions (but best in the one just below). You can also **Try it Offline!** (simplified solution incrementing by 4, works only in 1.11+) **by running this command in a command block**.

---

### Old solution, Minecraft 1.9.0+, 186 blytes:

Since TNT normally explode after 3.0s in Minecraft, this one has to be placed by a command (`/setblock`) with a specified fuse. Also uses a more compact design to remove redundant command block (containing 42 bytes) and redstone against the older versions. I'm sure this can't get any lower...

### Older solution, Minecraft 1.9.0+, 232 blytes:

Oops, I found out these older solutions increment by 4...

Uses the 1.9 command block chain feature (green block thing) to save blocks. Also uses a more compact signal shortener then in the older solutions

### Even older solution, Minecraft 1.7.0+, 240 blytes:

Uses a more compact timer (TNT) then the first solution (below).

### Oldest solution, Minecraft 1.7.0+, 262 blytes:

---

This is so long because of the way Minecraft handles variables:

* To define a variable (int): `scoreboard objectives add <variable> dummy`
* To set a value to a variable (each entity including players has it's own variable value): `scoreboard players set <entity> <variable> <value>`

+ `*` can be used as `<entity>` to select all entities and save bytes.
    + only defined variables may be used
    + the value of the variable must be set to a number, not a variable
* To increment var1 by var2: `scoreboard players operation <entity> var1 += <entity> var2`

+ `<entity>` must be a single entity, eg. `@p`, not `*`

---

Screenshots are of my own, dual licenced under WTFPL and what licence SE decides to use today (currently `cc by-sa 3.0 with attribution required`) :-)

# Answer
> 39 votes
# Bash + linux utilities, 19

```
seq 40 2 72|pv -qlL2

```

`seq` generates the numerical output. `pv` ratelimits it to 2 lines/sec.

# Answer
> 18 votes
# Vim, ~~24~~, 23 bytes/keystrokes

```
i40<esc>qq:sl500m
Yp2<C-a>q15@q

```

*One byte saved thanks to @Kritixi Lithos!*

Written from my phone, tested in mobile vim (which is apparently a real thing).

Here's a gif of it running:

And here is a command-by-command explanation:

```
i40<esc>            " Insert '40' into the buffer
        qq          " Start recording into register 'q'
          :sl500m   " Sleep form 500 ms
Y                   " Yank this line
 p                  " and paste it on a newline
  2<C-a>            " Increment this line twice
        q           " Stop recording
         15@q       " Callback register 'q' 15 times

```

# Answer
> 10 votes
# JavaScript (ES6), 52 bytes

```
f=(i=40)=>console.log(i)|i-72&&setTimeout(f,500,i+2)

f()
```

# Answer
> 7 votes
# Jelly, ~~13~~ 12 bytes

```
40µṄœS.+2µ⁴¡

```

Try it online! The Jelly program is wrapped in a Bash script to prefix each line of output by a timestamp.

### How it works

```
40µṄœS.+2µ⁴¡  Main link. No arguments.

40             Set the return value to 40.
  µ      µ⁴¡  Execute the chain between the two µ 16 times.

   Ṅ           Print the return value, followed by a linefeed.
      .        Yield 0.5.
    œS         Sleep for 0.5 seconds. Yield the previous result.
       +2      Add 2.

```

After the last iteration, the final value of **72** is printed implicitly and the program exits.

# Answer
> 6 votes
# Perl 6, 30 bytes

```
for 20..36 {sleep .5;say 2*$_}

```

Sorry that it looks like un-golfed code, I don't see a way to make it shorter...

The version that stops right after the last number, would be 37 bytes:

```
for 20..36 {sleep .5 if $++;say 2*$_}

```

# Answer
> 5 votes
# Pyth - 12 bytes

Very simple, uses a for loop from 0-17.

```
V17+40yN.d.5

```

# Answer
> 4 votes
# MATL, 14 bytes

```
17:E38+".5Y.@D

```

Try it in MATL Online! You may need to reload the page if it doesn't initially work.

### Explanation

```
17:     % Push array [1 2 ... 17]
E       % Multiply by 2, element-wise
38+     % Add 38, element-wise. This gives [40 42 ... 72]
"       % For each k in that array
  .5Y.  %   Pause 0.5 seconds
  @D    %   Push k and display
        % End (implicit)

```

---

## Old version (before spec change), clearing the screen

```
17:E38+"5&Xx@D

```

Try it in MATL Online!

# Answer
> 4 votes
# TI-Basic (CE or CSE only), 16 bytes

```
:For(A,40,72
:Pause A,.5
:End

```

Note that many commands are single byte tokens.

# Answer
> 4 votes
# Dyalog APL, 20 bytes

```
{⎕DL.5⊣⎕←⍵}¨38+2×⍳17

```

`{` the anonymous function

`⎕DL` delay...

`.5⊣` half (a second) rather than the value of

`⎕←` print (with newline)

the argument

applied to each of

`38+` thirty eight plus

twice

`⍳17` the integers from 1 to 17

# Answer
> 4 votes
# C compiled with Clang 3.8.1 on Linux, ~~62~~ ~~59~~ 58 bytes

*2 bytes saved thanks to @ranisalt*

```
s=38;main(){for(;s<74;printf("%d\n",s+=2))usleep(500000);}

```

**59 bytes**

```
s=38;main(){for(;s<73;printf("%d\n",s+=2+usleep(500000)));}

```

**62 Bytes**

```
s=38;main(){for(;s!=72;){printf("%d\n",s+=2);usleep(500000);}}

s=38                # Initializes a global (int) variable, this is only possible in C, in other languages from the C family variables must have an explicit type.
main()              # Is the main entry point, again as before, in case a type isn't specified C defaults to int
printf("%d\n",s+=2) # printf outputs to stdout based on the pattern defined in the first parameter
                    # %d is a placeholder for an int variable
                    # \n appends a newline to stdout
                    # The second parameter increments the s variable and afterwards it goes in the placeholder's spot.
usleep(500000)      # This function is Linux specific, it takes an int as parameter, it represents how much time the app needs to sleep in microseconds

```

# Answer
> 3 votes
# Mathematica, 34 bytes

```
Pause[Print@#;.5]&/@Range[40,72,2]

```

Full program. Takes no input and outputs to STDOUT.

# Answer
> 3 votes
# Perl 6, 27 bytes

```
sleep .say/2 for 40,42...72

```

`say` returns `True`, which is coerced to a numeric `1` when divided by `2`.

Unicode shenanigans can get it down to 23 characters:

```
sleep .say/2 for ㊵,㊷…72

```

But that's 29 UTF-8-encoded bytes.

# Answer
> 3 votes
# Python 2, ~~57 56~~ 55 Bytes

```
import time
a=40
while a<73:print a;time.sleep(.5);a+=2

```

EDIT:

-1 Byte thanks to Mega Man

-1 Byte thanks to Flp.Tkc

# Answer
> 3 votes
## R, 49 bytes

```
x=38;while(x<72){Sys.sleep(.5);x=x+2;cat(x,"\n")}

```

Very trivial solution but it does the trick.

# Answer
> 3 votes
## QBIC, 21 bytes

```
[44,72,4|?a┘'sleep 1.

```

QBIC starts a FOR-loop, running from 44 to 72 and incrementing the counter by 4 on every loop. It then sleeps for 1 second. QBasic doesn't have a more finegrained control foor `sleep`, so I've added a `.` to simulate giving `.5` as an argument.

# Answer
> 3 votes
# Ruby 31 bytes

```
20.upto(36){|n|p n*2
sleep 0.5}

```

Try it online!

# Answer
> 3 votes
## Ruby, 33 bytes

```
(40).step(72,2){|n|p n;sleep 0.5}
```

# Answer
> 3 votes
# C#, 95 bytes

```
()=>{for(int i=40;i<73;i+=2){System.Console.WriteLine(i);System.Threading.Thread.Sleep(500);}};

```

It is a simple for loop, it waits an extra 500ms at the end.

# Answer
> 3 votes
# Kotlin, 47 bytes

I guess it was not said in the problem statement that solutions should actually contain increment by two, so the `40+2*i` is legal here.

If written as a regular Kotlin source with `main`:

```
fun main(args:Array<String>){(0..16).map{println(40+2*it);Thread.sleep(500)}}

```

(77 bytes)

**UPD**: In Kotlin 1.3, `args:Array<String>` can be removed, so it's 18 bytes less.

And in Kotlin Script, the whole program would be

```
(0..16).map{println(40+2*it);Thread.sleep(500)}

```

(47 bytes)

# Answer
> 2 votes
## Haskell, 67 bytes

```
import System.Posix.Unistd
mapM((>>usleep 500000).print)[40,42..70]

```

If you want to go with ghc only, you can save a few bytes by importing `GHC.Conc` and using `threadDelay` instead of `usleep`.

# Answer
> 2 votes
## Common Lisp, ~~57~~ 52

```
(loop for b from 40 while(<(print b)72)do(sleep .5))

```
* Print returns its input parameter.
* The program exits immediately after reaching 72.

Ungolfed:

```
(loop
  for b from 40
  do (print b)
  while (< b 72)
  do (sleep .5))

```

# Answer
> 2 votes
# php, 38 bytes

```
for(;35>$t+=2;usleep(5e5))echo$t+38,_;

```

uses underscore as delimiter. Run with `-nr`.

# Answer
> 2 votes
## Racket 46 bytes

```
(for((i(range 40 73 2)))(println i)(sleep .5))

```

Ungolfed:

```
(define (f)
  (for ((i (range 40 73 2)))
    (println i)
    (sleep .5)))

```

Command to run: `(f)`

# Answer
> 2 votes
## Clojure, 54 bytes

```
(doseq[t(range 32 73 2)](println t)(Thread/sleep 500))

```

Third lisp ftw. Just iterates over the range, printing and sleeping each iteration. Sleeps at the end.

Ungolfed:

```
(doseq [t (range 32 73 2)]
    (println t)
    (Thread/sleep 500)))

```

## A version that doesn't sleep at the end, 66 bytes

```
(doseq[t(range 32 73 2)](println t)(if(< t 72)(Thread/sleep 500)))

```

Note, these are full programs since the instructions don't specify. Add a byte to each if a function is required.

# Answer
> 2 votes
# Octave, ~~38~~ 35 bytes

*Saved 3 bytes thanks to @LuisMendo by changing `endfor` to `end`*

```
for i=20:36;disp(2*i);sleep(.5);end

```

Try it online!

I am new to Octave, so this solution still might be golfed further. Any tips are welcome!

### Ungolfed

```
for i=20:36
  disp(2*i)
  sleep(.5)
end

```

# Answer
> 2 votes
# Python 2, ~~57~~ 58 Bytes

**Edit**

Counted as 57 bytes on my handy but TIO says 58 now that I'm back on my own machine so that's my final offer. Interestingly enough TIO doesn't seem to respect the timeout and just waits and then prints out the whole list in one go. Works on QPython for Android and Python 2 on my Ubuntu box so that's good enough for me.

```
import time
for x in range(40,74,2):print x;time.sleep(.5)

```

Try it online!

Would be ~~58~~ 59 in Python 3 so doesn't beat @sonrad10 anyway.

# Answer
> 2 votes
# R, ~~44~~ 42 bytes

Straightforward for-loop, there's likely a golfier way. (Also, crossed-out 44 is still regular 44...)

```
for(i in 20:36*2)cat(i,"\n",Sys.sleep(.5))

```

# Answer
> 2 votes
# Browser Javascript, ~~52~~ 51 chars

```
eval(s="s=alert(x=setTimeout(s,500)*2+38)|x<69&&s")

```

Test with `console.log` instead of `alert`:

```
eval(s="s=console.log(x=setTimeout(s,500)*2+38)|x<69&&s")
```

# Answer
> 2 votes
# F#, 60 bytes

`async{for i in 40..2..72 do printfn"%d"i;do!Async.Sleep 500}`

This is an async expression, in order to run it pass it into `Async.Start` or `Async.RunSynchronously`.

# Answer
> 2 votes
# Noodel, noncompeting 10 bytes

Cannot compete because *Noodel* was born after the challenge was created:(

```
40Ḷ16ñ++ḍh

```

Try it:)

### How it works

```
40         # Creates the literal number 40 and places it into the pipe.
  Ḷ16      # Loop the following code 16 times.
     ñ     # Print what is in the front of the pipe with a new line.
      ++   # Increment what is in the pipe by two.
        ḍh # Delay for a half a second (500ms).

```

---

There is not a version of *Noodel* that supports the syntax used in this answer. Here is a version that is correct:

```
kȥḶ16ñ⁺2ḍh

```

```
<div id="noodel" code="kȥḶ16ñ⁺2ḍh" input="" cols="10" rows="17"></div>

<script src="https://tkellehe.github.io/noodel/noodel-latest.js"></script>
<script src="https://tkellehe.github.io/noodel/ppcg.min.js"></script>
```

# Answer
> 2 votes
# Windows Batch - ~~65 62~~ 61 bytes

*btw this is my first PPCG answer*

```
@for /l %%p in (40,2,72)do @echo %%p&@ping 1.1 -n 1 -w 10>nul

```

This exits when the degree reaches 72.

---

# ~~76~~ 75 bytes - Does not sleep at end

```
@for /l %%p in (40,2,72)do @echo %%p&if %%p lss 72 @ping 1.1 -n 1 -w 10>nul

```

---

Ungolfed and explanation:

```
@echo off                           - Turns of the prompt(C:\Foo\Bar\Baz>)
for /l %%p in (40,2,72) do (        - For loop that loops from 40 to 72, increase 2 each
    echo %%p                        - Outputs the loop counter(which is the temp.)

if %%p lss 72 (                     - If loop counter is less than 72,
        ping -n 1 -w 10 1.1 >nul    - ping an non-existing IP to make delay

                                    - note: ping will always make 500ms delay
                                    - if waiting time is less than 500ms
    )                               - Closing bracket(if statement)

)                                   - Closing bracket(for statement)

```

# Answer
> 2 votes
# Excel VBA (32-Bit Only), 123 Bytes

Declares the windows Kernel32 Sleep(ByVal dwMilliseconds as Long) function and uses a recursive helper function. Outputs to the VBE immediate window.

```
Declare Sub Sleep Lib"kernel32"(ByVal t&)
Sub a(i)
Debug.?i
If i<72Then Sleep 500:DoEvents:a i+2
End Sub
Sub b:a 40:End Sub

```

**Usage and Ouput**

as seen from an `b` subroutine call from the VBE immediate window

```
b        ''  <- Subroutine Call
 40      ''  <- Output
 42
 44
 46
 48
 50
 52
 54
 56
 58
 60
 62
 64
 66
 68
 70
 72

```

# Answer
> 2 votes
# PowerShell, ~~32~~ 31 bytes

```
40..72|%{$_[$_%2];sleep -m 250}

```

Try it online!

Sleeps regardless if it's odd or even for half the time but will only output when the value is even due to out-of-bounds indexing returning nothing. Lost several bytes due to sleep defaulting to seconds and only taking ints.

# Answer
> 1 votes
## \*\>\<\>, 20 bytes

```
"H&"v
?;5S>2+:n:{:}=

```

Try it here!

This outputs the 40 and adds two every 500ms, outputting the new number. At 72 the program does not wait and exits immediately. Wasn't sure if we needed any sort of deliminator in-between the temperatures so there isn't one included.

### Explanation

```
Setup:

"J("   push 72 and 38 (temp) to the stack
    v  enter main loop at ">"

Main loop:

>               move the IP right
 2+             add two to temp
   :n           copy and output temp
     :{:}       copy temp and 72
         =?;    if temp == 72, exit
            5S  sleep 500ms

```

# Answer
> 1 votes
# Factor, 36 bytes

```
20 36 [a,b] [ 2 * . 5e8 sleep ] each

```

Pretty simple.

# Answer
> 1 votes
# Python 3, 61 bytes

Not a winner, but a horrible, horrible abuse of a list comprehension: two side-effects and the result isn't even used.

```
import time
[print(2*x+40)==time.sleep(.5)for x in range(17)]

```

Similar:

```
[time.sleep(.5)for x in map(print,range(40,74,2))]

```

# Answer
> 1 votes
# Python 2, 54 bytes

Thanks @xnor for cutting 2 bytes off!

```
import time;x=40
exec'print x;x+=2;time.sleep(.5);'*17

```

# 55 bytes

This one uses a dfferent counting approach, can probably still be golfed:

```
import time;x=34
while x:print 74-x;x-=2;time.sleep(.5)

```

# Answer
> 1 votes
# GNU sed, 87 + 1 = 88 bytes

+1 byte for `-u` flag (prevents sed from waiting until the end to flush all of the output).

Assumes it's running in an environment where the shell command `sleep .5` works.

```
s/.*/40/
:
p
esleep .5
/72/Q
/8/bz
h
y/0246/2468/
s/.//
H
x
s/.\n//
b
:z
y/4568/5670/
b

```

Try it online! (Using Dennis' handy bash wrapper to timestamp each output line.)

# Answer
> 1 votes
# RBX.Lua, 36 bytes

Uses **UTF-8** encoding. Golfed:

```
for i=40,72,2 do wait(.5)print(i)end

```

Should be pretty obvious to people with Lua knowledge. Here's an explanation:

```
for i=40,72,2 do --For-loop, counting from 40 to 72 in steps of 2.
wait(.5) --RBX.Lua builtin. Waits 0.5 seconds.
print(i) --Prints current temperature.
end --End of for loop.

```

# Answer
> 1 votes
# Java, 93 bytes

```
a->{for(a=38;(a+=2)<73;){System.out.println(a);try{Thread.sleep(500);}catch(Exception e){}}};

```

This is a `java.util.function.Consumer<Integer>` that makes me want to take a `new NullPointerException()` and use it to slap whoever who made `Thread.sleep()` throw a checked exception.

Identical-in-length snippet that does the exact same thing with an "everyday" method:

```
void a(int A)throws Exception{for(A=38;(A+=2)<73;){System.out.println(a);Thread.sleep(500);}}

```

# Answer
> 1 votes
## postgresql9.6, 162 bytes

```
do language plpgsql $$ declare n smallint;begin foreach n in array array(select generate_series(40,72,2))loop raise info'%',n;perform pg_sleep(.5);end loop;end;$$

```

formatted sql is here:

```
do language plpgsql $$
declare n smallint;
begin
foreach n in array array(select generate_series(40, 72, 2)) loop
    raise info '%', n;
    perform pg_sleep(.5);
end loop;
end;
$$

```

# Answer
> 1 votes
# ForceLang, 71 bytes

For some unknown reason, does not quite work if you run the interpreter using Eclipse, but still functions properly if you run the interpreter using your terminal directly. ¯\\\_(ツ)\_/¯

```
set s 38
label 1
io.writeln set s s+2
datetime.wait 500
if -72+s
goto 1

```

# Answer
> 1 votes
# SAS, 60 bytes

Something different :)

```
data _null_;do i=40 to 72; put i;s=sleep(.5,1);end;run;

```

# Answer
> 1 votes
# Swift, 208 bytes

```
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
func n(){if t<72{DispatchQueue.main.asyncAfter(deadline:.now()+0.5){t+=2;print(t);n()}}}
var t=40;print(t);n()

```

`sleep()` takes a `UInt32` in Swift, so won't work for the 500 millisecond delay. If it was 1 second however:

```
import Foundation;(20...36).map{$0*2}.forEach{print($0);sleep(1)}

```

**65 bytes** (with a delay at the end)

# Answer
> 1 votes
# Python 2, 57 bytes

```
import time as t
x=40
while x<73:print x;t.sleep(.5);x+=2

```

This does require an 'extra' newline to actually run, so arguably response is 58 bytes (please feel free to edit/comment if this is what the figure above should be).

Edit: Remove unecessary whitespace between : and print

Edit2: changed 0.5 to .5, saving one byte.

Edit3: failed to add/count the sleep import, which raises the score to 60 bytes.

Edit4: Saved 3 bytes by adding extra line

# Answer
> 1 votes
**101, ~~98~~ 78 bytes**

```
00001 101000 001 11 00001 01001000 00001 0001 000010 1111 00001 1001 000101 111

```

EDIT: The language has beed updated to support equals etc. So i managed to narrow it down a little. Note: i did not update the explaination.

developed a programming language in python over the course of the 2 last days. Its fairly simple, but is a pain to program in, as it consists only of 1's and 0's, and can only hold binary numbers with up to 6 numbers.

Explenation:

```
00001 101000 # declares variable 00001 to 40
00010 100010 # declares variable 00010 to 34

001 00010 # start of loop, checks if variable 00010 is over 0
00010 0011 000010 # 0011 is the function for decrementing, and i decrement by 2 (decimal)
1111 00001 # 1111 is the function for printing
00001 0001 000010 # same as above, only addition
1001 000101 # 1001 is timer, takes a whole number and divide by 10 to allow milliseconds
111 # same as end symbol in ruby

```

EDIT: Link to the language https://github.com/hrrs01/101 Easily tested by running the demo file by doing (if python in PATH):

> 101.py demo.txt

# Answer
> 1 votes
# Common Lisp, 54 bytes (45 if trailing newline is allowed)

```
(dotimes(i 17)(format t"~a~&"(+(* 2 i)40))(sleep 0.5))

```

shorter - with trailing newline, because `print` adds one:

```
(dotimes(i 17)(print(+(* 2 i)40))(sleep 0.5))

```

# Answer
> 1 votes
# RbxLua, 36 bytes

```
for i=40,72,2 do print(i)Wait(.5)end

```

Thought I'd use RbxLua, which is a modified version of Lua 5.1 used on ROBLOX.com, as it has a built-in Wait(s) function that is one byte shorter than sleep(ms) in Lua 5.3.

Edit: Didn't see the other RbxLua solution. This solution uses a non-deprecated form of wait.

# Answer
> 1 votes
# dc, 50 bytes

```
0sm[40lm+p0se[le1+dse120000>j]dsjxlm2+dsm33>p]dspx

```

Well, this seems to be the first answer which does *not* utilize any `sleep` built-in as `dc` seemingly does not have one. Instead, this simply utilizes a macro loop which during each of `16` iterations increments `40` by `2*iteration #`, outputs the sum on a new-line, and utilizes another macro loop which is iterated through `120000` times giving us our desired `500 millisecond` sleep with a very slight and unnoticeable variance.

# Answer
> 1 votes
# 05AB1E, 11 bytes

```
40žvƒ=Ì₄;.W

```

Try it online.

**Explanation:**

```
40           # Push 40
  žvƒ        # Loop 17 times (in the range [0,16]):
     =       #  Print the top of the stack with newline (without popping)
      Ì      #  Increase the number by 2
       ₄;    #  Push 1000 halved to 500
         .W  #  And sleep that many ms

```

# Answer
> 0 votes
**Javascript (ES6), 48 bytes**

```
f=(i=40)=>alert(i)|i-72&&setTimeout(f,500,i+2)

f()
```

> Based on @ETHproductions answer.

# Answer
> 0 votes
# Zsh, 34 bytes

```
for i ({40..72..2})<<<$i&&sleep .5

```

Attempt This Online!

---
Tags: code-golf, string, kolmogorov-complexity, date, animation
---


title: There are known knowns

text:
# Question
Title: There are known knowns
Former US Secretary of Defense, Donald Rumsfeld, famously popularized the phrase "known knowns." Here we're going to distill his remarks into a four-line stanza.

Specifically, output this text:

```
known knowns
known unknowns
unknown knowns
unknown unknowns

```

Capitalization doesn't matter (for example, `Known unKnowns` is fine), and a single trailing newline is acceptable, but no other formatting changes are allowed. That means a single space between the words, and either `LF` (59 bytes) or `CR/LF` (62 bytes) between the lines.

### Rules

* Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
* Standard loopholes are forbidden.
* This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

# Answer
# Python 2, ~~54~~ 52 bytes

-2 bytes thanks to xnor

```
k='unknowns'
for i in 8,6,2,0:print k[i/3:7],k[i%3:]

```

Try it online!

The results from the `/` and `%` will be `[[2, 2], [2, 0], [0, 2], [0, 0]]` that will be the starting indexes, removing the `un` when `2`, keeping the string unaltered when `0`
> 30 votes

# Answer
# Vim ~~28~~ 25 bytes

This is my first Vim answer, any golfing tips are welcome.

```
2iunknown ␛rsY3P2xw.+.jw.

```

Thank you Lynn for writing the python script to make that fantastic animation.

This can also be run by V Try it Online!

Also 25:

```
2iknown ␛rsY3pwiun␛+.+.w.

```
> 28 votes

# Answer
# bash, 36 bytes

```
printf %s\\n {,un}known\ {,un}knowns

```

other solutions

36

```
eval echo\ {,un}known\ {,un}knowns\;

```

37

```
eval printf '%s\\n' \{,un}known{\\,s}

```

38

```
eval eval echo\\ \{,un}known{\\,'s\;'}

```

41

```
x=\\\ {,un}known;eval "eval echo$x$x\s\;"

```

45

```
x='\ {,un}known' e=eval;$e "$e echo$x$x\s\;"
x='\ {,un}known' e=eval\ ;$e"$e\echo$x$x\s\;"

```

if leading newline and extra space were accepted 31 bytes :

```
echo '
'{,un}known\ {,un}knowns

```
> 23 votes

# Answer
# 05AB1E, ~~13~~ 12 bytes

Saved 1 byte thanks to *Erik the Outgolfer* (avoid closing string)

```
„Š¢—‚#D's«â»

```

Try it online!

**Explanation**

```
„Š¢—‚           # push the string "known unknown"
     #          # split on spaces
      D         # duplicate
       's«      # append "s" to each
          â     # cartesian product
           »    # join on newline

```
> 14 votes

# Answer
## CJam (26 25 bytes)

```
"unknown"_2>\]2m*{S*'sN}%

```

Online demo

Cartesian product of `["known" "unknown"]` with itself, then each element joined with space and suffixed with `s` and a newline.

Thanks to Erik for a one-byte saving.
> 11 votes

# Answer
# , ~~52~~ ~~51~~ 50 bytes

```
cat(gsub(1,"known","1 1s
1 un1s
un1 1s
un1 un1s"))

```

Try it online!

Surprisingly short substitution and print commands make this an *actually competitive* R answer in a challenge!

~~Even if it's super boring.~~ Mildly more interesting now, and with a byte saved thanks to J.Doe!

Saved another byte thanks to this answer, also by J.Doe!
> 8 votes

# Answer
# Haskell, ~~60~~ ~~58~~ ~~53~~ 51 bytes

```
f<$>l<*>l
f x y=x++' ':y++"s"
l=["known","unknown"]

```

Try it online!

Yields a list of lines as was recently allowed. Thanks to @firefrorefiddle for pointing out.

-2 bytes thanks to cole.

---

**58 byte version:**

```
f=<<"? ?s\n? un?s\nun? ?s\nun? un?s"
f '?'="known"
f c=[c]

```

Try it online! Yields a single string.
> 6 votes

# Answer
## Retina, ~~33~~ 32 bytes

*Saved 1 byte using an intermediate printing approach from Leo.*

```

 ¶u

knowns
u
 un
:`s

m`^
un

```

Try it online!

### Explanation

```

 ¶u

```

Turns the non-existent (i.e. empty) input into the string on the second line. That one seems pretty weird, but these characters are codes for the stuff that goes *between* two instances of `known[s]` on the first two lines of the result. Space and linefeed are just themselves and `u` is  `un`.

```

knowns

```

Now we insert `knowns` at every position (i.e. at the beginning, end, and between every pair of characters).

```
u
 un

```

We decode the `u`.

```
:s

```

Then we get rid of the `s`s in front of spaces, i.e. those in the first half of each line, and print the result.

```
m`^
un

```

And finally we prepend `un` to both lines and print the result again.

This beats the trivial approach of just using a placeholder for `known` by 4 bytes, but not Neil's more efficient implementation of that approach.
> 5 votes

# Answer
# Retina, ~~33~~ 32 bytes

```

 s¶ uns¶un s¶un uns
 |s
known$&

```

Try it online! Edit: Saved 1 byte thanks to @ovs. Explanation: This is almost the trivial approach of using a placeholder for `known`, except here I simply insert it before each space or `s`, which saves ~~3~~ 4 bytes.
> 5 votes

# Answer
# C# (.NET Core), 54 bytes

```
v=>@"z zs
z unzs
unz zs
unz unzs".Replace("z","known")

```

Try it online!
> 5 votes

# Answer
# PHP, ~~55 51~~ 47 bytes

```
<?=strtr("1 1s
1 01s
01 1s
01 01s",[un,known]);

```

try it online
> 5 votes

# Answer
# Shakespeare Programming Language, ~~1021~~ ~~1012~~ 993 bytes

*-19 bytes thanks to Joe King!*

```
,.Ajax,.Ford,.Page,.Act I:.Scene I:.[Exeunt][Enter Ajax and Ford]Ajax:Am I nicer a big cat?If sois the remainder of the quotient betweenI the sum ofa cat a big cat worse a big cat?If notlet usScene V.You be the sum ofa fat fat fat pig the cube ofthe sum ofa cat a big big cat.Speak thy.You be the sum ofyou the sum ofa cat a fat fat fat pig.Speak thy.Scene V:.[Exit Ajax][Enter Page]Page:You be the product ofthe sum ofa cat a big big cat the sum ofa pig a big big big big cat.Speak thy.You be the sum ofyou the sum ofa cat a big cat.Speak thy.Ford:You be the sum ofI a cat.Speak thy.You be the sum ofyou a big big big cat.Speak thy.Page:Speak thy.You be the sum ofyou the sum ofa cat a big big cat.Is the remainder of the quotient betweenAjax a big cat worse a cat?If soyou big big big big big cat.Speak thy.If solet usScene X.You be twice the sum ofa cat a big big cat.Speak thy.Scene X:.[Exit Page][Enter Ajax]Ford:You be the sum ofyou a cat.Be you worse a big big big cat?If solet usAct I.

```

Try it online!
> 5 votes

# Answer
# APL (Dyalog), ~~64~~ ~~47~~ 35 bytes

```
⍪,∘.{⍺,' ',⍵,'s'}⍨k('un',k←'known')

```

Try it online!

**How?**

`k←'known'` \- `k` is `"known"`

`k('un',k←'known')` \- `"known" "unknown"`

`∘.`... \- outer product with itself

`{⍺,' ',⍵,'s'}` \- with the function that formats the args as `{⍺} {⍵}s`

`,` \- smash the product table into vector

\- separate to columns
> 4 votes

# Answer
# C (gcc),  ~~79~~   ~~78~~  76 bytes

*Thanks to @Justin Mariner for golfing one byte!*

```
f(){printf("%s %1$ss\n%1$s un%1$ss\nun%1$s %1$ss\nun%1$s un%1$ss","known");}

```

Try it online!
> 4 votes

# Answer
# Java 8, ~~56~~ 55 bytes

```
v->" s\n uns\nun s\nun uns".replaceAll(" |s","known$0")

```

-1 byte thanks to *@SuperChafouin*.

**Explanation:**

Try it here.

```
v->                         // Method with empty unused parameter
  " s\n uns\nun s\nun uns"  //  Literal String
   .replaceAll(" |s",       //  Replace all spaces and "s" with:
     "known                 //   Literal "known"
           $0")             //   + the match (the space or "s")
                            // End of method (implicit / single-line return-statement)

```
> 4 votes

# Answer
# Perl 6, 45 bytes

```
$_='known';.say for [X](($_,"un$_")xx 2)X~'s'

```

Try it

## Expanded

```
$_ = 'known';

.say                # print with trailing newline the value in topic variable ｢$_｣

  for               # do that for each of the following

    [X](
      ($_, "un$_")  # ('known','unknown')
        xx 2        # list repeated twice
    ) X~ 's'        # cross using &infix:«~» with 's' (adds ｢s｣ to the end)

```

The `[X](…)` part generates

```
(("known","known"),("known","unknown"),("unknown","known"),("unknown","unknown")).Seq

```

Then using `X~` on it coerces the inner lists into a Str (because of the `&infix:«~»` operator), which doing so adds a space between values.

```
("known known", "known unknown", "unknown known", "unknown unknown").Seq

```

Then each is joined with an `s`

```
("known knowns", "known unknowns", "unknown knowns", "unknown unknowns").Seq

```
> 4 votes

# Answer
## Haskell, ~~57~~ 52 bytes

```
id=<<id=<<mapM(\s->[s,"un"++s])["known ","knowns\n"]

```

Try it online!
> 4 votes

# Answer
# Jelly, 15 bytes

```
“ṿ1“ŒwƘ»pż€⁾ sY

```

Try it online!
> 3 votes

# Answer
## Perl 5, 33 bytes

**Disclaimer**: I didn't realise that brace expansion was possible within the `<...>` operator (learned thanks to @Grimy's answer!) and the using the clever expansion trick from @NahuelFouilleul's amazing bash answer, I was able to build this solution. I will happily remove this at either of their request.

```
print<"{,un}known {,un}knowns$/">

```

Try it online!

---

## Perl 5, 42 bytes

**41 bytes code + 1 for `-p`.**

```
s//K Ks
K unKs/;s/K/known/g;$\=s/^/un/gmr

```

Try it online!

---

# Perl 5, 45 bytes

Tried to come up with an alternative, but couldn't make it shorter... Thought it was different enough to warrant adding anyway.

```
print"un"x/[3467]/,known,$_%2?"s
":$"for 0..7

```

Try it online!
> 3 votes

# Answer
# Ruby, ~~53~~ 50 bytes

```
$><<"a as
a unas
una as
una unas".gsub(?a,"known")

```
> 3 votes

# Answer
# Husk, 14 bytes

```
OΠṠemhw¨ṅW∫ḟωμ

```

Try it online!

# Explanation

```
OΠṠemhw¨ṅW∫ḟωμ
       ¨ṅW∫ḟωμ    The compressed string "knowns unknowns"
      w           Split on spaces ["knowns","unknowns"]
   e              Make a list with:
    mh             this list with the last letter dropped from each word
  Ṡ                and this same list
                  [["known","unknown"],["knowns","unknowns"]]
 Π                Cartesian product [["known","knowns"],["unknown","knowns"],["known","unknowns"],["unknown","unknowns"]]
O                 Sort the list [["known","knowns"],["known","unknowns"],["unknown","knowns"],["unknown","unknowns"]]
                  Implicitely print joining with spaces and newlines

```
> 3 votes

# Answer
# Haskell, ~~71~~ ~~66~~ ~~56~~ 54 bytes

```
(<*>).map((++).init)<*>map(' ':)$["knowns","unknowns"]

```

Thanks to @Leo for -3 bytes!

Note: In the question's comments, the o.p. said that returning a list of strings is okay

Try it here.
> 3 votes

# Answer
# 6502 machine code (C64), 48 bytes

```
00 C0 A9 37 85 FB A9 73 4D 2B C0 8D 2B C0 A9 0D 4D 2C C0 8D 2C C0 A9 26 90 02
E9 02 A0 C0 20 1E AB 06 FB D0 E1 60 55 4E 4B 4E 4F 57 4E 53 0D 00

```

**Online demo**

**Usage:** `sys49152`

---

### How it works

The trick here is to use a "loop counter" for 8 iterations where bits 7 to 1 of the initial value are `1` for `unknown(s)` and `0` for `known(s)` in one iteration. This counter is shifted to the left after each iteration (shifting the leftmost bit into the carry flag) and bit `0` is initially `1` so we know we're finished once the last bit was shifted out. In the first iteration, `known` is printed because when calling the program, the carry flag is clear.

In each iteration, the end of the string is toggled between `<space>` and `s<newline>`.

Here's the commented disassembly listing:

```
         00 C0            .WORD $C000    ; load address
.C:c000  A9 37            LDA #$37       ; initialize loop counter ...
.C:c002  85 FB            STA $FB        ; ... as 0011 0111, see description
.C:c004   .loop:
.C:c004  A9 73            LDA #('s'^' ') ; toggle between 's' and space
.C:c006  4D 2B C0         EOR .plural
.C:c009  8D 2B C0         STA .plural
.C:c00c  A9 0D            LDA #$0D       ; toggle between newline and 0
.C:c00e  4D 2C C0         EOR .newline
.C:c011  8D 2C C0         STA .newline
.C:c014  A9 26            LDA #<.knowns  ; start at "known" except
.C:c016  90 02            BCC .noprefix  ; when carry set from shifting $fb:
.C:c018  E9 02            SBC #$02       ; than start at "un"
.C:c01a   .noprefix:
.C:c01a  A0 C0            LDY #>.knowns  ; high-byte of string start
.C:c01c  20 1E AB         JSR $AB1E      ; output 0-terminated string
.C:c01f  06 FB            ASL $FB        ; shift loop counter
.C:c021  D0 E1            BNE .loop      ; repeat if not 0 yet
.C:c023  60               RTS            ; done
.C:c024   .unknowns:
.C:c024  55 4E           .BYTE "un"
.C:c026   .knowns:
.C:c026  4B 4E 4F 57 4E  .BYTE "known"
.C:c02b   .plural:
.C:c02b  53              .BYTE "s"
.C:c02c   .newline
.C:c02c  0D 00           .BYTE $0d, $00

```
> 3 votes

# Answer
## Batch, 66 bytes

```
@set s= in (known unknown)do @
@for %%a%s%for %%b%s%echo %%a %%bs

```

Alternative answer, also 66 bytes:

```
@for %%a in (k unk)do @for %%b in (k unk) do @echo %%anown %%bnowns

```
> 2 votes

# Answer
# T-SQL, ~~56~~ 54 bytes

```
PRINT REPLACE('1 1s
1 un1s
un1 1s
un1 un1s',1,'known')

```

SQL supports line breaks inside string literals, so similar to some other languages already posted.

**EDIT**: Slightly longer (**82 bytes**), but a bit more clever:

```
SELECT k+s+k+p+k+s+u+p+u+s+k+p+u+s+u+p
FROM(SELECT'known'k,' 's,'unknown'u,'s
'p)t

```

**EDIT 2**: My favorite so far, using a cross-self-join from a derived table (**79 bytes**):

```
WITH t AS(SELECT'known'a UNION SELECT'unknown')
SELECT z.a+' '+t.a+'s'FROM t,t z

```

**EDIT 3**: Changed the replacement character from `'x'` to `1`, which lets me remove the quotes around it and save 2 bytes, since `REPLACE` does an implicit conversion to string.
> 2 votes

# Answer
# Haxe, 71 bytes

```
(?x)->[for(a in x=["","un"])for(b in x)a+'known ${b}knowns'].join("\n")

```

Try it online!
> 2 votes

# Answer
# PowerShell, ~~46~~ 44 bytes

```
' s
 uns
un s
un uns'-replace' |s','known$&'

```

Try it online!

(Almost) simple string replacement. Uses Neil's approach to trim two bytes. Thanks to Martin for pointing that out.

Sadly, it's shorter than the more interesting cross-product method by ~~three~~ ~~five~~ three bytes:

## PowerShell, ~~49~~ 47 bytes

```
($a='known','unknown')|%{$i=$_;$a|%{"$i $_`s"}}

```

Try it online!
> 2 votes

# Answer
# Jq 1.5, 47 bytes

```
"K Ks
K unKs
unK Ks
unK unKs"|gsub("K";"known")

```

Try it online!
> 2 votes

# Answer
# Javascript ~~66 54 53~~ 50 bytes

```
_=>` s
 uns
un s
un uns`.replace(/ |s/g,'known$&')

```

### History

* saved 12 bytes thanks to @someone (explicit usage of "un" in the main string)
* saved 1 byte thanks to @ThePirateBay (split..join instead of replace)
* saved 3 bytes thanks to @Neil (better replace())
> 1 votes

# Answer
# ReRegex, 38 bytes

```
a/known/a as\na unas\nuna as\nuna unas

```

Try it online!
> 1 votes

# Answer
# Bash, ~~60~~ ~~57~~ ~~54~~ 52 bytes

```
b=${a=known}s;echo "$a $b
$a un$b
un$a $b
un$a un$b"

```

Try it online!

* L3viathan: -3
* Dom Hastings: -3
* manatwork: -2

Thank you guys!
> 1 votes

# Answer
# Vim, 28 keystrokes

```
iknown <C-n>s<CR><C-X><C-l><S-Left>un<Esc>o<C-p><Left> <C-n><Esc>o<C-p><C-p> <C-p>s

```

Also 28:

```
iknown <C-n>s<Esc>qqo<C-X><C-l><S-Left>un<Esc>qo<C-p><Left> <C-n><Esc>@q

```
> 1 votes

# Answer
# C (gcc), ~~70~~ 66 bytes

Thanks to @l4m2 for -4 bytes!

```
f(i){for(i=8;i--;)printf("unknown%s"+(i>4|i==2)*2,i%2?" ":"s\n");}

```

Try it online!
> 1 votes

# Answer
# Haskell, 49 bytes

```
unwords<$>mapM(\s->[s,"un"++s])["known","knowns"]

```

Try it online!
> 1 votes

# Answer
# C, gcc, 64 bytes

```
c="unknown";f(i){for(i=4;i--;)printf("%s %ss\n",i&2|c,i%2*2+c);}

```

Seems doesn't work on TIO, but works fine on my coputer
> 1 votes

# Answer
# ed, 52 bytes

```
a
known knowns
.
,t1
2s/ k/ unk/
,t2
3,4s/^k/unk/
w

```

Try it online!
> 1 votes

# Answer
## **Python 3, 69 bytes**

```
k=['known','unknown']
for i in range(4):print(k[i//2]+' '+k[i%2]+'s')

```
> 1 votes

# Answer
# Underload, 58 bytes

```
((:^)(s
)( )(known):(un)~*):^!:S~SSS^~S~SSS^S~SSS^~!:S~SSS

```

Uses a simple lookup table with a lot of `S`s.

Try it Online!
> 1 votes

# Answer
# Wolfram Language (Mathematica), 46 bytes

```
Outer[Print[#,a=nown," ",#2,a,s]&,b={k,unk},b]

```

Try it online!
> 1 votes

# Answer
# ink, 39 bytes

```
-(i){||un}known {&|un}knowns
{i<10:->i}

```

Try it online!
> 1 votes

# Answer
# Octave, 55 bytes

```
[{'un','known',[115,10],32}{'bdbcbdabcabdbcabdabc'-96}]

```

Try it online!

### Explanation:

First, we create a cell array with four strings: `un`, `known`, `s\n` and . Then we create a string `bdbcbdabcabdbcabdabc` that becomes the appropriate indices when we subtract 96: `a=1, b=2, c=3, d=4`. We index the cell array using cell indexing `{}`, and concatenate the result using brackets `[]`.

---

The following is one byte *longer* than the output itself.

```
printf(strrep(', ,s\n, un,s\nun, ,s\nun, un,s',',','known'))

```
> 0 votes

# Answer
# IBM/Lotus Notes Formula, 78 bytes

```
@ReplaceSubstring("a as,a bas,ba as,ba bas";"a":"b":",";"known":"un":@Newline)

```

Not the shortest but actually shorter than just hard coding the strings in @Formula.

Formula language allows lists as the `from` and `to` parameters to `@ReplaceSubstring`. Just a shame that `@ReplaceSubstring` itself costs 17 bytes and `@Newline` costs 4 more than `"\n"`.
> 0 votes

# Answer
# Batch, 78 bytes

```
@set a=known
@echo %a% %a%s&echo %a% un%a%s&echo un%a% %a%s&echo un%a% un%a%s

```

Quite hard to golf, everything non-trivial I tried so far just makes it longer.
> 0 votes

# Answer
# , 25 bytes

Two solutions, both 25 bytes

```
2iunknowns |exÄwxxäj2xj.

```

Try it online!

Hexdump:

```
00000000: 3269 756e 6b6e 6f77 6e73 201b 7c65 78c4  2iunknowns .|ex.
00000010: 7778 78e4 6a32 786a 2e                   wxx.j2xj.

```

And

```
2iunknown Äwxxäj2xj.Î$rs

```

Try it online!

Hexdump:

```
00000000: 3269 756e 6b6e 6f77 6e20 1bc4 7778 78e4  2iunknown ..wxx.
00000010: 6a32 786a 2ece 2472 73                   j2xj..$rs

```
> 0 votes

# Answer
# , 39 bytes

```
echo@;@,"1//' s'|.@;"0/(;'un',])'known'

```

Try it online!

Here's another one, that I'll explain instead (53 chars):

```
;"1((<<<2)&{,],48&A.,:n)({.,' ';n=.'un';])'known';'s'

```

|

```
                        ({.,' ';n=.'un';])'known';'s'

```

Yields `["known", " ", "un", "known", "s"]` and defines `n` that adds "un" in front. Then for each of the 4 lines respectively we

```
    (<<<2)&{                     Remove "un", the 2nd string
             ]                   Do nothing
               48&A.             Move "un" to the front
                      n          Add "un"
;"1                              Smash the lines.

```

2,0,1,3,4 is #48 in the alphabetically sorted list of permutations of 0,1,2,3,4. I've no idea how it's implemented.
> 0 votes

# Answer
# Pyth, 28 bytes

-1 byte thanks to hakr14.

```
jm+j;d\s^_c"unknown known"d2

```

**Try it here!**
> 0 votes

# Answer
# ///, 35 bytes

```
/2/un1//1/known/1 1s
1 2s
2 1s
2 2s

```

Try it online!
> 0 votes

# Answer
# K (oK), 41 bytes

**Solution:**

```
(1_',/x,/:\:x:(" known";" unknown")),'"s"

```

Try it online!

**Explanation:**

This still feels clunky, but this is the shortest version yet:

```
(1_',/x,/:\:x:(" known";" unknown")),'"s" / the solution
(                                  ),'"s" / append "s" to each left
              (" known";" unknown")       / 2-item list of " known" and " unknown"
            x:                            / save as variable x
      x,/:\:                              / x concatenate each right (/:) with each left (\:)
    ,/                                    / flatten lists
 1_'                                      / drop first item from each list (ie drop the leading whitespace)

```

**Notes:**

Other versions:

```
/ 49 bytes, just join each right/each left and flatten
,/("known";"unknown"),/:\:(" knowns";" unknowns")

/ 43 bytes, try to be smarter building the known/knowns
,/2 0_/:\:"unknown ",/:("";"un"),\:"knowns"

```
> 0 votes

# Answer
# Japt `-R`, 22 bytes

```
`kÍ5 unkÍ5`¸
ïUm+'s)m¸

```

Test it
> 0 votes

# Answer
# Pyth, 24 bytes

```
jm+j;d\s^_>B"unknown"2 2

```

Try it online here.

```
jm+j;d\s^_>B"unknown"2 2
            "unknown"      String literal
          >          2     Remove the first two letters
           B               Pair the above with the original string - ["unknown", "known"]
         _                 Reverse
        ^              2   Cartesian product with itself
 m                         Map each pair, as d, using:
   j;d                       Join on spaces
  +   \s                     Append "s"
j                          Join on newlines, implicit print

```
> 0 votes

# Answer
## Burlesque - 29 bytes

```
"unknown"J2.-CLJcp{wd's_+}muQ

"unknown"J                     duplicate
          2.-                  drop 2
             CL                collect stack
               J               duplicate
                cp             cross product
                  {            begin block
                   wd          words
                     's_+      append `s`
                         }     end block
                          mu   map unlines
                            Q  pretty print

```

Try it online.

*Alternate versions*:

```
"known unknown"wdJcp{wd's_+}muQ

```
> 0 votes

# Answer
# MathGolf, ~~23~~ ~~19~~ 18 bytes

```
4♀*(╦_╢Ñ▌]■{ u's+p

```

Try it online!

## Explanation

I really need some base-250 integers

```
4♀*(                 Push 4, push 100, multiply, decrement (resulting in 399)
    ╦                Fetch dictionary word with index 399
     _               Duplicate
      ╢Ñ             Push "un"
        ▌            Prepend to TOS
         ]           Wrap stack in array
          ■          Cartesian product with itself
           {         For-each
             u       Join with space (space character is before the "u")
              's+    Add "s"
                 p   Print

```
> 0 votes

# Answer
# JavaScript, 78 bytes

This is my first-ever attempt at solving a code golf, so all suggestions welcome!

```
console.log(k=(u="unknown").substr(2),k+(s="s")+(n="\n")+k,u+s+n+u,k+s+n+u,u+s)
```

### Explanation

Step 1: `k=(u="unknown").substr(2)`. The `u="unknown"` evaluates to "unknown". A substring of this, from char #2 until the end of the string, is then assigned to variable `k`. This whole thing evaulutes to the outermost assignment, "known", which is the first parameter to `console.log`.

Step 2: Next is a `,`. Each parameter to `console.log` is printed with a space in between, so a `,` represents a space in the output. The current output is "known ".

Step 3: `k+(s="s")` evalutates to "knowns", and at the same time assigns "s" to the variable `s`, to be used as a shorthand for later. The current output is "known knowns"

Step 4: `+(n="\n")+k`. We append a newline to this, and store the newline character as a shorthand for later. We also append `k`. The current output is "known knowns{newline}known".

Step 5: `,u+s+n+u,k+s+n+u,u+s)` the rest is very simple: just appending `k`, `s`, and `u`, using `,`s for spaces, to spell out the rest of the output.

Like I said, this is my first-ever code golf, so I would appreciate any tips/tricks.
> 0 votes

# Answer
# Dart, ~~62~~ 61 bytes

```
g({s='known'})=>"$s $s\s\n$s un$s\s\nun$s $s\s\nun$s un$s\s";

```

Try it online!
> 0 votes

# Answer
# Stax, 15 bytes

```
┬τj%7↕▬α0▄╘δ₧▲\

```

Run and debug it

* Split compressed string "known unknown"
* Self Cross-product to produce all pairs
* For each, join with space, and append "s".
> 0 votes

# Answer
# Wolfram Language (Mathematica), 57 bytes

```
StringReplace["K Ks
K unKs
unK Ks
unK unKs","K"->"known"]

```

Try it online!
> 0 votes

# Answer
# Vyxal `j`, 15 bytes, (@lyxal)

```
`»² ¢λ`⌈:ẊvṄ\s+

```

Try it Online!

# Vyxal `j`, 18 bytes

```
`»²`:‛unp":\svpẊvṄ

```

Try it Online!

Vyxal has really improved my productivity, I wrote this in just 2 minutes.

```
`»²`    Dictionary compressed string "known"
:         Duplicate ^
‛un     Two byte string `un`
p         Prepend un to known
"          Pair the two words as a list
:          Duplicate ^
\s       Single byte char "s"
vp       Vectorised append to the duplicated lost
Ẋ         Take cartesian product of two lists
vṄ      Vectorised join by space in each ordered pair of the ^
            (Implicit join with newlines, by j flag)

```
> 0 votes

# Answer
# Zsh, 27 bytes

```
>{,un}known\ {,un}knowns
ls

```

Attempt This Online!

Or, a slightly cheaty version which outputs to a file called `known knowns`:

## Zsh, 26 bytes

```
ls>{,un}known\ {,un}knowns

```

Attempt This Online!
> 0 votes

---
Tags: code-golf, string, kolmogorov-complexity
---


title: Hack into a Lottery

text:
# Question
Title: 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!

# Answer
> 29 votes
# 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.

# Answer
> 44 votes
# C, 26 bytes

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

```

Prints a `unsigned long` value.

Requires the size of `long` to be 64 bits.

# Answer
> 35 votes
## 64-bit SBCL Common Lisp, 18 bytes

`most-positive-word`

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

# Answer
> 31 votes
## CJam (4 bytes)

```
GG#(

```

Online demo

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

# Answer
> 25 votes
# 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.

repl.it \<- testing link.

# Answer
> 16 votes
# bc, ~~15~~ 13 bytes

*Saved 2 bytes thanks to manatwork.*

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

```

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

# Answer
> 14 votes
## 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!**

# Answer
> 12 votes
# 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!

Another 4 byte answer:

```
ž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)

# Answer
> 11 votes
# Jelly, 4 bytes

```
⁴*`’

```

Try it online!

**Explanation**

```
⁴     # 16
 *    # exponentiate
  `   # last link as a monad, repeating the argument
   ’  # decrement

```

# Answer
> 11 votes
# 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.

# Answer
> 10 votes
# Java (JDK), 28 bytes

```
v->Long.toUnsignedString(~0)

```

Try it online!

# Answer
> 7 votes
# bc, ~~18~~, 16 bytes

* Saved 2 bytes, thx @MrScapegrace

```
(9-7)^(55+9)-3/3

```

# Answer
> 7 votes
### 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 1111111111111111111111111111111111111111111111111111111111111111 in binary, in 64 bits, compared to 11111111111111111111111111111111 in 32-bits, and the numbers are plataform-dependent - Ismael Miguel

# Answer
> 6 votes
## 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.

# Answer
> 6 votes
# 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.

# Answer
> 5 votes
## JavaScript, ~~39~~ ~~38~~ ~~33~~ 32 bytes

```
alert(0xafebff0+'737095'+0xc99f)

```

Edit: Saved 5 bytes thanks to @Arnauld.

# Answer
> 5 votes
# BF, 108 bytes

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

```

If each command is considered as 3 bits, this is potentially 41 bytes.

# Answer
> 5 votes
# Retina, ~~28~~ 27 bytes

*Saved 1 byte thanks to Kritixi Lithos*

```

bieegheeahdhajffbgbf
T`l`d

```

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.

```
T`l`d

```

This is a `T`ransliteration 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`.

# Answer
> 5 votes
# 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.

# Answer
> 5 votes
## 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

# Answer
> 5 votes
# JavaScript (ES6), 50 bytes

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

```

# Answer
> 5 votes
# 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 :)

# Answer
> 4 votes
# 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);}}

```

# Answer
> 4 votes
# Forth (gforth), ~~11~~ ~~9~~ 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.

# Answer
> 4 votes
# R, 58 bytes

R has only 32-bit integers, and with 64-bit doubles, the number 18446744073709551615 is not accurately represented, hence this will return a string. I can't even use 64-bit integer packages, because many of them have `64` in the names. Probably not the right tool for the job.

```
x=as.character((9+7)^(9+7))
n=nchar(x)
substr(x,n,n)='5';x

```

computes `16^16` and replaces the last character with a `5`.

Try it online!

# Answer
> 3 votes
# 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

```

# Answer
> 3 votes
# 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!

# Answer
> 3 votes
# Swift, 8 bytes

```
UInt.max

```

### outside playground / repl - 15 bytes

```
print(UInt.max)

```

# Answer
> 3 votes
# TI-Basic, 10 bytes

```
9+7
Ans^Ans-0!

```

# Answer
> 3 votes
# 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.

# Answer
> 3 votes
# JavaScript, 50 bytes 47 bytes

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

```

# Answer
> 3 votes
# Pyth, 6 bytes

```
C*h7"ÿ

```

Try it online!

## How it works

```
C*h7"ÿ
    "ÿ   creates the string "ÿ" (U+00FF)
  h7     creates 8 (7+1)
 *       generates "ÿÿÿÿÿÿÿÿ"
C        convert to integer from base 256

```

This works because `18446744073709551615 = 0xFFFFFFFFFFFFFFFF`.

# Answer
> 3 votes
# MathGolf, 3 bytes

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

```
♦ó(

```

Try it online!

# Answer
> 3 votes
# 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).+.?(

```

# Answer
> 2 votes
# Jelly, 7 bytes

```
3’*“@‘’

```

Try it online!

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
## 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

# Answer
> 2 votes
# C#, 20 bytes

```
()=>ulong.MaxValue;

```

# Answer
> 2 votes
## Ruby, ~~16~~ 12 bytes

```
p~0^~0>>~077

```

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

# Answer
> 2 votes
## 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

# Answer
> 2 votes
# 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`.

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# 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 `Z`s 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`.

# Answer
> 2 votes
# 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!

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# 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

```

# Answer
> 2 votes
# JavaScript, ~~67~~ ~~52~~ ~~47~~ ~~45~~ 39 bytes

```
b=9+7;(b**b+'').substr(0,b)+btoa('×y')

```

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# 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

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# Python 2, 21 bytes

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

```

Try it online!

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

# Answer
> 2 votes
# 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!

# Answer
> 2 votes
# Julia 1.0, ~~17~~ 15 bytes

```
print(~UInt(0))

```

Try it online!

# Answer
> 2 votes
# 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...

# Answer
> 2 votes
# Nim, 14 bytes

```
echo high uint

```

Attempt This Online!

# Answer
> 1 votes
# 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*

# Answer
> 1 votes
# Japt, 17 bytes

```
GpG s r#È*A+PG+Fs

```

Try it online!

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# Cardinal 42 bytes

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

```

Try it Online

# Answer
> 1 votes
# Rust, ~~43~~ ~~42~~ 31 bytes

```
fn main(){print!("{}",!0usize)}

```

This isn't portable code (assumes a 64-bit architecture), but I can't use the `u64` type due to its name containing forbidden characters.

# Answer
> 1 votes
# 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.

```

# Answer
> 1 votes
# \>\<\>, ~~17~~ 15 bytes

### Updates

* Replaced `ab--` with `i+` to achieve -1.

```
b5+:*:*:*:*i+n;

```

Try it online!

The idea is to factor 1616 into (((162)2)2)2, which can be easily computing by duplicating the stack and multiplying `:*`.

## Explanation

```
b5+:*:*:*:*i+n;

b                     Push 11
 5                    Push 5
  +                   Add to make 16
   :*                 Square  ->  16²
     :*:*:*           .. another 3 times to make
                           16¹⁶ = (((16²)²)²)²
           i          Push -1 because no input
            +         16¹⁶ + (-1) = 16¹⁶-1
             n;       Print and Exit

```

# Answer
> 1 votes
# Brain-Flak, 122 bytes

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

```

Try it online! Also works in Mini-Flak

# Answer
> 1 votes
# Java, 92 Bytes :-D

```
class a{public static void main(String[] a){System.out.print(Long.toUnsignedString(-3/3));}}

```

# Answer
> 1 votes
# JavaScript, ~~34~~ 25 bytes (courtesy of l4m2)

```
(a=BigInt(9+7))**a-a/a+''

```

Works in any console that supports `BigInt`s.

# Answer
> 1 votes
# Keg, 6 bytes

```
\∑\@Ë;

```

Try it online!

# Answer
> 1 votes
# Attache, 12 bytes

```
{$`e^$`G-!0}

```

Try it online!

Uses Attache's inbuilt number compression literals. `$`<string>` decompresses `<string>` into a number. In this case, `e` maps to `4`, and `G` to `32`. Another solution would be to replace both with `$`q`, which maps to `16`. We subtract 1, which can be calculated as `!0`, or \\$0!\\$. This is a lambda returning the appropriate value.

# Answer
> 1 votes
# x86\_64 machine code (Linux), 7 bytes

```
00000000: 4831 c048 f7d0 c3                        H1.H...

```

Assembly (NASM):

```
section .text
global func
func:
xor rax, rax
not rax
ret

```

Try it online!

# Answer
> 1 votes
# Vyxal, 4 bytes

```
kḭ²‹

```

Try it Online!

2^32 squared, minus one.

# Answer
> 1 votes
# Fig, \\$7\log\_{256}(96)\approx\\$ 5.762 bytes

```
{^{3C/@

```

Try it online!

```
{^{3C/@
  {3    # 3 - 1
 ^      # To the power of
    C/     # The charcode of
      @    # '@' (64)
{       # Decremented

```

# Answer
> 0 votes
## Batch, ~~64~~ ~~59~~ ~~58~~ 54 bytes

```
@set a=@cmd/cset/a
%a%0xafebff0
%a%737095
%a%0xc99f

```

Port of my JavaScript answer. Edit: Saved 5 bytes thanks to @Arnauld.

# Answer
> 0 votes
## Python, 19 bytes

In REPL

```
int('3'*(35-3),7-3)

```

Not in REPL

```
print int('3'*(35-3),7-3)

```

# Answer
> 0 votes
## Pyke, 5 bytes

```
Zw`@t

```

Try it here!

```
 w`   -   64
Z  @  -  set_bit(0, ^)
    t - ^ -1

```

# Answer
> 0 votes
# Ruby, 18 bytes

```
p (9+7)**(9+7)-7/7

```

# Answer
> 0 votes
# MUMPS, 15 bytes

```
w 9+7**(9+7)-'0

```

# Answer
> 0 votes
# SmallTalk – 60 characters

```
Transcript show:(((7+9)raisedTo:(7+9))-(3/3))printString;cr.

```

# Answer
> 0 votes
# SmileBASIC, 35 bytes

```
?POW(!.+!.,#X)LOCATE #A,0?ASC("x")

```

`x` should be replaced with `CHR$(1615)`

# Answer
> 0 votes
# Groovy, 28 Bytes

```
{++(Long.MAX_VALUE/0.5)}

```

Try it: https://groovyconsole.appspot.com/edit/5145694419550208

# Answer
> 0 votes
# asm2bf, 9 bytes

Function body assuming `r1 = 0`, returns the desired value in `r1`.

```
decr1
ret

```

# Answer
> 0 votes
# Japt, 10 bytes

```
GîGpG)+#¡5

```

Try it

```
GîGpG)+#¡5
G              :16
 î             :Slice the following to that length
  GpG          :  16**16
     )         :End slice
      +        :Append
       #¡5     :1615

```

# Answer
> 0 votes
# Whitespace, 61 bytes

```
[S S S T    S N
_Push_2][S N
S _Duplicate][T S S N
_Multiply][S N
S _Duplicate][T S S N
_Multiply][S N
S _Duplicate][T S S N
_Multiply][S N
S _Duplicate][T S S N
_Multiply][S N
S _Duplicate][T S S N
_Multiply][S N
S _Duplicate][T S S N
_Multiply][S S S T  N
_Push_1][T  S S T   _Subtract][T    N
S T _Print_as_integer]

```

Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.
`[..._some_action]` added as explanation only.

**Try it online** (with raw spaces, tabs and new-lines only).

**Explanation:**

Pretty straight-forward:

1. Push 2
2. Square itself six times
3. Decrease by 1
4. Output as integer

Pushing and outputting the expected integer in one go would be 72 bytes instead.

# Answer
> 0 votes
# Factor (Windows only), 14 bytes

```
GPTR on-bits .

```

Only works on Windows (and hence not on TIO/ATO). Not sure whether that's allowed or not.

GPTR is a constant equal to 64 loaded on machines running Windows. `on-bits` takes a value and creates a number with that many on bits.

# Answer
> 0 votes
# Fig, 17 bytes (UTF-8)

```
OC"䠎ᴐ᳊╏ɧ

```

Try it online!

Fig doesn't have too much in the way of number builtins, so here is a charcode version. Just get the charcode of each character, then join.

# Answer
> 0 votes
# C (gcc), 9 bytes

```
-Df()0UL-

```

Try it online!

Tech used before

# Answer
> 0 votes
# Pyt, 5 bytes

```
3⁻⁸⁸⁻

3⁻     pushes 3, then decrements
  ⁸    raises to the 8th power
   ⁸   8th power again
    ⁻  decrement
       implicit print

```

Try it online!

# Answer
> 0 votes
# Gol\>\<\>, 8 bytes

```
"@"XMn;

```

Try it online!

The unprintable is char `0x02`

# Explanation

```
".@"XMn; # whole program
".@"     # 0x02, 64
    X    # e`X`ponentiate
     m   # -1
      n  # output
       ; # terminate execution

```

# Answer
> 0 votes
# Thunno, \\$ 10 \log\_{256}(96) \approx \\$ 8.23 bytes

```
aeaA,D^nA~

```

Attempt This Online!

No numbers at all!

#### Explanation

```
aeaA,D^nA~  #                           STACK:
ae          # Constant for 160          160
  aA        # Constant for 10           160, 10
    ,       # Integer divide            16
     D^     # To the power of itself    18446744073709551616
       n    # Negate                    -18446744073709551616
        A~  # Bitwise not               18446744073709551615
            # Implicit output

```

# Answer
> 0 votes
# Stax, 4 bytes

```
VuJv

```

Run and debug it

Unpacked and packed it's 4 bytes

# Explanation

```
Vu   # 2**32
  J  # squared
   v # -1

```

# Answer
> 0 votes
# Zsh, 27 bytes

```
!
<<<$?$[35#ULOSOKRBNKG]$?5

```

Attempt This Online!

Zsh only allows signed 64 bit integers, so we need a string method. Notice that `ULOSOKRBNKG` is `84467440737095516` in base 35, and contains no disallowed characters. Then we just need to attach two `1`s and a `5`: 5 is an allowed digit anyway, and we can get 1 by running a command that fails (in this case `!`) and taking its exit status in `$?`.

# Answer
> -1 votes
# Python, 20 (or 26) bytes

```
(5-3)**ord('@')-3**0

```

`ord('@')` is equal to 64.

The full function/programme (@BusinessCat, I hope this is more in line with what is expected) would add 6 bytes:

```
print (5-3)**ord('@')-3**0

```

The 26 byte version would work if we wanted to pipe the output:

```
python -c "print (5-3)**ord('@')-3**0"

```

The 20 byte version would not.

---
Tags: code-golf, number, kolmogorov-complexity, restricted-source
---