# Question
Title: First person to ever beat Classic Tetris
# Historic Tetris Achievement

Blue Scuti became the first ever human to beat the classic game of Tetris on NES.

Here's the Tetris Kill Screen

# Challenge

Output the following Tetris `Kill Screen` board (10x20 blocks)

```
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEGGEEEE
EEEEBGGEEE
EBEEBBGGEE
EBEGBBBGBE
EEEEEEEEEE
BBGEBBGGBB
BBBEBBEGBB
BBBBBBBGBE
GGEBBBBBBB
GGEGBGGBBB
BBEBBGGGBB

```

| Code | Color |
| --- | --- |
| B | Blue |
| G | Green |
| E | Black |

# Rules

There is no strict requirement to use the characters B, G, and E, or a specific board orientation, as long as the concept of the `Kill Screen` is preserved.

# Examples

```
 Original    Rotate 180°
██████████   ░░▓▓▓░░█░░
██████████   ░░░▓▓░▓█▓▓
██████████   ░░░░░░░█▓▓
██████████   █░▓░░░░░░░
██████████   ░░▓█░░█░░░
██████████   ░░▓▓░░█▓░░
██████████   ██████████
██████████   █░▓░░░▓█░█
██████████   ██▓▓░░██░█
████▓▓████   ███▓▓░████     Rotate left 90°        Rotate right 90°
████░▓▓███   ████▓▓████   ██████████████░░█░░░   ░▓▓░░░██████████████
█░██░░▓▓██   ██████████   ████████████░█░░░░░░   ░▓▓░░░█░░███████████
█░█▓░░░▓░█   ██████████   ███████████▓▓█▓▓▓░░▓   ███░░▓██████████████
██████████   ██████████   ██████████▓▓░█▓█░░▓▓   ░▓░░███▓████████████
░░▓█░░▓▓░░   ██████████   █████████▓▓░░█░░░░▓▓   ░░░░░░█░░░▓█████████
░░░█░░█▓░░   ██████████   █████████▓░░░█░░░░░░   ▓▓░░░░█░░▓▓█████████
░░░░░░░▓░█   ██████████   ████████████▓███░░▓░   ▓▓░░█▓█░▓▓██████████
▓▓█░░░░░░░   ██████████   ██████████████▓░░███   ▓░░▓▓▓█▓▓███████████
▓▓█▓░▓▓░░░   ██████████   ███████████░░█░░░▓▓░   ░░░░░░█░████████████
░░█░░▓▓▓░░   ██████████   ██████████████░░░▓▓░   ░░░█░░██████████████

0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 0 0 0 0 0 0  1111111111  ..........
0 0 0 0 1 1 0 0 0 0  1111221111  ....##....                            ""
0 0 0 0 2 1 1 0 0 0  1111022111  ....O##...  00000000000000220222      !""
0 2 0 0 2 2 1 1 0 0  1011002211  .O..OO##..  00000000000020222222   !  !!""
0 2 0 1 2 2 2 1 2 0  1012000201  .O.#OOO#O.  00000000000110111221   ! "!!!"!
0 0 0 0 0 0 0 0 0 0  1111111111  ..........  00000000001120102211
2 2 1 0 2 2 1 1 2 2  0021002200  OO#.OO##OO  00000000011220222211  !!" !!""!!
2 2 2 0 2 2 0 1 2 2  0001001200  OOO.OO.#OO  00000000012220222222  !!! !! "!!
2 2 2 2 2 2 2 1 2 0  0000000201  OOOOOOO#O.  00000000000010002212  !!!!!!!"!
1 1 0 2 2 2 2 2 2 2  2210000000  ##.OOOOOOO  00000000000000122000  "" !!!!!!!
1 1 0 1 2 1 1 2 2 2  2212022000  ##.#O##OOO  00000000000220222112  "" "!""!!!
2 2 0 2 2 1 1 1 2 2  0010022200  OO.OO###OO  00000000000000222112  !! !!"""!!

```

# Answer
> 2 votes
# Whitespace, ~~695~~ 682 bytes

```
[S S S T    S N
_Push_2_!][S N
S _Duplicate_2_!][S S S T   T   N
_Push_3_"][S N
S _Duplicate_3_"][S N
S _Duplicate_3_"][S S S T   S N
_Push_2_!][S N
S _Duplicate_2_!][S S S T   N
_Push_1_<space>][S S S T    S N
_Push_2_!][S N
S _Duplicate_2_!][S S T T   S T S T N
_Push_-21_\n][S S S T   S N
_Push_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S S S T   T   N
_Push_3_"][S N
S _Duplicate_3_"][S S S T   S N
_Push_2_!][S S S T  T   N
_Push_3_"][S S S T  N
_Push_1_<space>][S S S T    T   N
_Push_3_"][S N
S _Duplicate_3_"][S S T T   S T S T N
_Push_-21_\n][S S S T   S N
_Push_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S S S T   N
_Push_1_<space>][S S S T    T   N
_Push_3_"][S N
S _Duplicate_3_"][S S T T   S T S T N
_Push_-21_\n][S S S T   N
_Push_1_<space>][S S S T    S N
_Push_2_!][S S S T  T   N
_Push_3_"][S S S T  S N
_Push_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S S T T   S T S T N
_Push_-21_\n][S S S T   S N
_Push_2_!][S N
S _Duplicate_2_!][S S S T   T   N
_Push_3_"][S S S T  N
_Push_1_<space>][S S S T    S N
_Push_2_!][S N
S _Duplicate_2_!][S S S T   N
_Push_1_<space>][S S S T    S N
_Push_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S S T T   S T S T N
_Push_-21_\n][S S S T   S N
_Push_2_!][S N
S _Duplicate_2_!][S S S T   T   N
_Push_3_"][S N
S _Duplicate_3_"][S S S T   S N
_Push_2_!][S N
S _Duplicate_2_!][S S S T   N
_Push_1_<space>][S S S T    T   N
_Push_3_"][S S S T  S N
_Push_2_!][S N
S _Duplicate_2_!][S S T T   S T S T N
_Push_-21_\n][S S S T   N
_Push_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S S T   T   S T S T N
_Push_-21_\n][S S S T   N
_Push_1_<space>][S S S T    S N
_Push_2_!][S S S T  T   N
_Push_3_"][S S S T  S N
_Push_2_!][S N
S _Duplicate_2_!][S N
S _Duplicate_2_!][S S S T   T   N
_Push_3_"][S S S T  N
_Push_1_<space>][S S S T    S N
_Push_2_!][S S S T  N
_Push_1_<space>][S S T  T   S T S T N
_Push_-21_\n][S S S T   N
_Push_1_<space>][S N
S _Duplicate_1_<space>][S S S T T   N
_Push_3_"][S N
S _Duplicate_3_"][S S S T   S N
_Push_2_!][S N
S _Duplicate_2_!][S S S T   N
_Push_1_<space>][S N
S _Duplicate_1_<space>][S S S T S N
_Push_2_!][S S S T  N
_Push_1_<space>][S S T  T   S T S T N
_Push_-21_\n][S S S T   N
_Push_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S S S T T   N
_Push_3_"][S N
S _Duplicate_3_"][S S S T   S N
_Push_2_!][S S S T  N
_Push_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S S T   T   S T S T N
_Push_-21_\n][S S S T   N
_Push_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S S S T T   N
_Push_3_"][S N
S _Duplicate_3_"][S S S T   N
_Push_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S S S N
_Push_0][S S S T    S S T   N
_Push_9][T  T   S _Store][N
S S S N
_Create_Label_LOOP1][S S T  T   S T S T N
_Push_-21_\n][S S S T   N
_Push_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S N
S _Duplicate_1_<space>][S S S N
_Push_0][T  T   T   _Retrieve][S S S T  N
_Push_1][T  S S T   _Subtract][S N
S _Duplicate][S S S N
_Push_0][S N
T   _Swap_top_two][T    T   S _Store][N
T   S N
_If_0_Jump_to_Label_LOOP2][N
S N
S N
_Jump_to_Label_LOOP1][N
S S N
_Create_Label_LOOP2][S S S T    T   T   T   T   N
_Push_31][T S S S _Add_top_two][T   N
S S _Output_as_character][N
S N
N
_Jump_to_Label_LOOP2]

```

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).

Outputs with `! "` instead of `BEG` to save 13 bytes.
(Here the TIO for the old/longer program: Try it online with `BEG` as output.)

**Explanation in pseudo-code:**

```
Push the codepoint-integers minus 31 of string '!!"""!! !!\n
                                                !!!""!" ""\n
                                                !!!!!!! ""\n
                                                 !"!!!!!!!\n
                                                !!" !! !!!\n
                                                !!""!! "!!\n
                                                          \n
                                                 !"!!!" ! \n
                                                  ""!!  ! \n
                                                   ""!    \n
                                                    ""    '
a=9
Start LOOP1:
  Push the codepoint-integers minus 31 of string '\n
                                                            '
  a = a-1
  If a==0:
    Jump to LOOP2
  Go to next iteration of LOOP1

LOOP2:
  Add 31 to the top integer
  Print it as character with this codepoint to STDOUT
  Go to next iteration of LOOP2

```

The constant `31` is generated by this Java program, based on this Whitespace tip of mine.

# Answer
> 10 votes
# C (gcc), ~~476~~ ~~395~~ ~~308~~ ~~283~~ ~~153~~ 151 bytes

*-130 bytes thanks to @Command Master<br>-2 bytes thanks to @ceilingcat*

Applying ANSI escape codes to the ascii-art.

```
*a=L"sssssssss7%77%-#'%#1s''%'1''Y%Y%%1''/'";b;main(c){for(;c=*a++;(b+=c/5-3)%20||puts(""))printf("[4%dm %*s",c%5,c/5,"[0m");}

```

Try it online

**Output**

Linux Terminal

# Answer
> 6 votes
# Python, ~~114~~ 112 bytes

```
x=int("cmlzatvntfmkheiwxpk0p5iob21d1xxc29",36)
c='0'*90
while x:c+=str(x%3);x//=3
while c:print(c[:10]);c=c[10:]

```

Attempt This Online!

This isn't winning any code golf, but it's an interesting concept I wanted to try out before. Basically it is the last 11 rows concatenated, interpreted as a base-3 number, then reversed. Of course, storing the data in the source code as a ~~hex~~ base-36 number wastes a lot of bits, and the printing and decoding can be optimized much further.

# Python, 106 bytes

```
lambda i=200,x=int("2mwpsm5yo9be8gwx4tjcljqj9lx0jxigz",36):f(i-1,x//3)+str(x%3)+'\n'[i%10<1]if i else''

```

Attempt This Online!

This is the program rewritten as a function returning the result, based on l4m2's answer. Before the `\n` there's a ZWSP that is counted in the byte-count but technically means the string has a bunch of extra non-printing spaces.

Very rough constant generation code:

```
b="""EEEEGGEEEE
EEEEBGGEEE
EBEEBBGGEE
EBEGBBBGBE
EEEEEEEEEE
BBGEBBGGBB
BBBEBBEGBB
BBBBBBBGBE
GGEBBBBBBB
GGEGBGGBBB
BBEBBGGGBB"""
b = b.replace('E','0').replace('G','1').replace('B','2')
b = b.replace('\n','')[::-1]
x = int(b,3)
print(hex(x))

```

# Answer
> 6 votes
# Zsh, 98 bytes

```
repeat 9 <<<1111111111
for w (MJ4 M3D KS7 QY7 MS4 150Z 15LQ QZZ 19JR 1809 14OH)rev<<<$[[##3]36#$w]

```

Attempt This Online!

Converts each line from base 36 to base 3. Each line is reversed, because no line ends with a `G` (`0`), so we can avoid needing to pad with zeroes.

Generator

# Answer
> 6 votes
# Jelly, 32 bytes

```
“ṚƝ*ẊḢ-PṇḃeḶ:@İñṇY¤kṂė’b3Ż94¡s⁵Y

```

Try it online!

A niladic link that outputs the kill screen with 0 for E, 1 for G and 2 for B. A base-250 encoded integer that is converted to base 3, prepended with 94 zeros, split into pieces length 10 and then joined with new lines.

# Answer
> 5 votes
# Funge-98, 165 bytes

```
 9\wv>58k:9k.a,1+:
    v3> ^j3:k35,a<
  2p>53k:3k.7:..'^e
v>k.2277722523k:772757725k:57752725k:227522523k:7722572258k:527222752555772255255557725k.a,
<,a.k9p10-1_@#:g10

```

Try it online!

Instead of `B`, `G`, and `E`, this program outputs `2`, `7`, and `5`.

Contains a tab, which does not seem to work in code blocks, so here is a hex dump:

```
00000000: 2039 5c77 763e 3538 6b3a 396b 2e61 2c31   9\wv>58k:9k.a,1
00000010: 2b3a 0a09 7633 3e20 5e6a 333a 6b33 352c  +:..v3> ^j3:k35,
00000020: 613c 0a20 2032 703e 3533 6b3a 336b 2e37  a<.  2p>53k:3k.7
00000030: 3a2e 2e27 5e65 0a76 3e6b 2e32 3237 3737  :..'^e.v>k.22777
00000040: 3232 3532 336b 3a37 3732 3735 3737 3235  22523k:772757725
00000050: 6b3a 3537 3735 3237 3235 6b3a 3232 3735  k:57752725k:2275
00000060: 3232 3532 336b 3a37 3732 3235 3732 3235  22523k:772257225
00000070: 386b 3a35 3237 3232 3237 3532 3535 3537  8k:5272227525557
00000080: 3732 3235 3532 3535 3535 3737 3235 6b2e  72255255557725k.
00000090: 612c 0a3c 2c61 2e6b 3970 3130 2d31 5f40  a,.<,a.k9p10-1_@
000000a0: 233a 6731 30                             #:g10

```

# Answer
> 4 votes
# Charcoal, ~~37~~ 35 bytes

```
ＧTχE⪪”{“⌈K→◧ψＭ^≡Ｎq§d5Ｇ↑℅a⁰≔)⦃L+y≡”χ

```

Try it online! Link is to verbose version of code. Explanation: The `ＧTχE` draws a `10×10` square of `E`s, leaving the cursor at the bottom left, so that the `10`th line will be overwritten as the bottom `11` lines are then drawn by splitting a compressed string into rows of `10` characters.

# Answer
> 3 votes
# Perl 5, 108 bytes

```
say for('}'x13 .']W}MJWeJURW]JMOZOJ}eROMRWjMRMOzROJMWMzWMOJWjMR_R')=~s,.,($&&G)x((63&ord$&)/8),gre=~/.{10}/g

```

Try it online!

# Answer
> 3 votes
# Ruby, ~~84~~ ~~83~~ 78 bytes

```
puts (?0*94+0x7241ea9db46487237308d479dcb396cc036e301ec3.to_s(3)).scan /.{10}/

```

Attempt This Online!

Ports Jelly, which to my surprise is extremely short in Ruby.

Previous solutions:

# Ruby, 86 bytes

```
puts [674,5102,9124,30937,96952,116639,2264,459,18212,716].map{_1.to_s(3).rjust 20,?0}

```

Attempt This Online!

Outputs the board rotated 90 degrees, rough port of my Japt solution.

## Ruby, ~~119~~ 114 bytes

```
puts [716,18212,459,2264,116639,96952,30937,9124,5102,674].map{_1.to_s(3).rjust(20,?0).chars}.transpose.map{_1*''}

```

Attempt This Online!

Un-rotated version of above solution.

# Answer
> 3 votes
# Assembly (nasm, x64, linux) 322 bytes

```
b dq 0,0,0,0,01ADB000000000h,0BEF21AC00033838h,0BFE67E8h,8455DEDA83BD4C42h,41B2938E84746B28h,8343133241A32656h
global _start
_start:mov r8,b
mov bl,20
l:mov eax,[r8]
mov rsi,rsp
mov rcx,10
mov[rsi],cl
r:mov dl,0
mov r9,10
div r9
add dl,48
dec si
mov[rsi],dl
loop r
mov al,1
mov dx,11
mov di,1
syscall
add r8,4
dec bl
jnz l

```

Try it online!

# Answer
> 3 votes
# Python 3.10.10, 164 bytes(UTF-8)

---

###### Definitely not the shortest, but oh well.

```
a="\n#.~"
for i in"ªªªZV¨ªªfU¡ªª¾ªª~n=ªª~Yõ¨ªzeU¡ªªºZªªª^*ªªjY}¨ªªjõ":w=ord(i)*4;print("".join(a[(w:=w//4)&3]for i in a),end="")

```

Try it online!

Outputs a 90deg rotated board, with some extra newlines.

## How

I packed 4 characters into a byte, using 2 bits for each character(`#`,`.`,`~`, or `\n`). Then, I just use `ord` to convert the ASCII junk back into integers, then unpack it.

#### Clever things:

* Since `for i in range(4)` is obviously way too long, I used `for i in a`, as `a` (coincidentally) has a `len` of 4, and I don't need the value of `i`(the second i) anyway.
* `*4` when assigning `w`, then `(w:=w//4)` in the loop, making use of the walrus operator. I originally had `a[w&3+0*(w:=w//4)]`, but then I realized I can just multiply the initial value of `w` by 4.

###### Misc note: I checked, `print(*(genexpr),sep="",end="")` is longer than `print("".join(genexpr),end="")`(by exactly 1 character)

# Answer
> 2 votes
# Python (3), ~~229~~ ~~142~~ ~~132~~ 125 bytes

```
x=0
while x<400:print(''.join("█░▓"[int('bie58lyn9recsv5ux1hcplbz7kxon7tmdbe9cplju',36)>>i&3]for i in range(x,x+20,2)));x+=20

```

Try it online

**Output (Rotated 180°)**

```
▓▓░░░▓▓█▓▓
▓▓▓░░▓░█░░
▓▓▓▓▓▓▓█░░
█▓░▓▓▓▓▓▓▓
▓▓░█▓▓█▓▓▓
▓▓░░▓▓█░▓▓
██████████
█▓░▓▓▓░█▓█
██░░▓▓██▓█
███░░▓████
████░░████
██████████
██████████
██████████
██████████
██████████
██████████
██████████
██████████
██████████

```

# Answer
> 2 votes
# JavaScript (Node.js), ~~159~~ ~~156~~ 153 bytes

```
console.log('94E2G8EB2G4EB2E2B2G3EBEG3BGB11E2BGE2B2G5BE2BEG9BGBE2GE7B2GEGB2G5BE2B3G2B'.replace(/(\d+)(.)/g,(_,t,c)=>c.repeat(t)).replace(/.{10}/g,`$&
`))

```

Try it online!

# Answer
> 2 votes
# JavaScript (Node.js), 92 bytes

```
f=(x=200,n=0xe482b7c850b79b07c4080ea138643fd606dacb4523n)=>x?f(x-1,n/3n)+n%3n+[`
`[x%10]]:''

```

Try it online!

# JavaScript (Node.js), 146 bytes

```
x=>(x=`EEEEEEEEEE
`).repeat(9)+`EEEEGGEEEE
EEEEBGGEEE
EBEEBBGGEE
EBEGBBBGBE
${x}BBGEBBGGBB
BBBEBBEGBB
BBBBBBBGBE
GGEBBBBBBB
GGEGBGGBBB
BBEBBGGGBB`

```

Try it online!

* +

# Answer
> 2 votes
# APL+WIN, 112 bytes, 109 bytes or 68 bytes

Prompts for characters to display. 3 bytes can be saved if a matrix of the integers 1 2 3 is allowed. Simply delete the first 2 characters and the last.

```
⎕[⍉(2×b⊤n,48 24 12 68 0 140 4 4 768 856 28)+((b←10⍴2)⊤(n←9⍴0),0 32 304 314 0 819 947 1018 127 39 867)+z←10 20⍴1]

```

Try it online! Thanks to Dyalog Classic

Alternatively using the base 3 approach with the integers 0 1 2 representing E G B

```
(9 10⍴0)⍪(11⍴3)⊤376 9124 594 4417 146893 166580 55205 18212 2551 337

```

Try it online! Thanks to Dyalog Classic

# Answer
> 2 votes
# Japt, ~~50~~ 49 bytes

```
`mcnhp4 bn26 3hsvn2Ô©u6pn8t4n4v l2`qÍ®nH3ÃùT20 Õ·

```

Test it

My idea was to compress the 10 columns as base-3, left-pad each with zeroes to length 20, and transpose. I think this is more optimal than compressing the 11 rows as base-3 and prepending 9 rows of zeroes, which seems to be the strategy most submissions are using right now.

The idea used by Nick Kennedy's clever Jelly solution doesn't translate to Japt because it doesn't have support for bigints without hooking into JS, and when you leave Japt-land you don't get compression, so the program ends up quite a bit longer.

# Japt `-R`, 47 bytes

```
`l2n4v8t4nu6pn2Ô©3hsvn26ebnhp4nmc`qÍ®nH3ÃùT20

```

Test it

Output rotated 90 degrees.

# Answer
> 2 votes
# Uiua, 104 bytes

```
≡(&p⊏:".O#"⇌)⬚0≡(≡/(+×2)↯⊟:2⌈÷2⧻.)⋯⊂⊚9+.640_1184_66856_68940_0_337197_345357_349516_169301_167093_332973

```

Pad

Outputs the following:

```
..........
..........
..........
..........
..........
..........
..........
..........
..........
....##....
....O##...
.O..OO##..
.O.#OOO#O.
..........
OO#.OO##OO
OOO.OO.#OO
OOOOOOO#O.
##.OOOOOOO
##.#O##OOO
OO.OO###OO

```

# Answer
> 2 votes
# Pip `-l`, 46 bytes

```
0X94.(A*"!`V(;O01U	_3^R@=Mc,c"FDh)TB3<>t

```

The code contains unprintable characters which do not display correctly on StackExchange. Here's a hexdump:

```
00000000: 3058 3934 2e28 412a 2203 2160 5628 3b4f  0X94.(A*".!`V(;O
00000010: 300c 3155 095f 330e 5e52 4016 3d4d 632c  0.1U._3.^R@.=Mc,
00000020: 1a08 6322 4644 6829 5442 333c 3e74       ..c"FDh)TB3<>t

```

Attempt This Online!

### Explanation

Basically the same idea as Nick Kennedy's Jelly answer, though Pip doesn't have the same base decompression builtin:

```
0X94.(A*"..."FDh)TB3<>t
                         t is 10; h is 100 (implicit)
        "..."            String of characters
      A*                 Get ASCII code of each
             FDh         Treat those as base-100 digits and convert to base 10
     (          )TB3     Convert to base 3
0X94.                    Prepend string of 94 zeros
                    <>t  Group into chunks of length 10
                         Print each on a separate line (-l flag)

```

I experimented with several bases and found 100 to give the best results. It's not the most efficient compression, but saving two bytes by writing `h` instead of `100` makes up for that.

# Answer
> 2 votes
# YASEPL, ~~131~~ 130 bytes

```
=m)"1"=a;m,10<<<<<<<<<;m,4~#44<~>944111#19>11994411>1914999491;m,10<=g;"9",2~#41~#44<~#91~#14<~~~>9491#441~~~>9#44149449<~#m~#444~

```

really annoying code but here's the output:

```
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111441111
1111944111
1911994411
1914999491
1111111111
9941994499
9991991499
9999999491
4419999999
4414944999
9919944499

```

uses 1, 4, and 9

edit : fixed an inconsistency

# Answer
> 1 votes
# Retina 0.8.2, 100 bytes

```

E93G1E7BG1E3BE1B1G1E2BEGB2GBE10B1GEB1G1B4EB1EGB8GBEG1EB6G1EGBG1B4EB1G2B1
\d+
$*
+`(.)1
$1$1
!`.{10}

```

Try it online! Explanation: Inspired by @mekb's JavaScript answer.

```

E93G1E7BG1E3BE1B1G1E2BEGB2GBE10B1GEB1G1B4EB1EGB8GBEG1EB6G1EGBG1B4EB1G2B1

```

Insert the RLE compressed string.

```
\d+
$*

```

Convert to unary.

```
+`(.)1
$1$1

```

Perform RLE decoding.

```
!`.{10}

```

Split into rows of `10` characters.

# Answer
> 1 votes
# Vyxal 3 `j`, 77 bytes

```
90'e×"∧.€¯uэuꜝ!¹»ġ«ᶳ⊻)pṚnṘᵞΘṆuĿġɾ⌐5Ṙ}Ч∥•Ɠ₌ᶳ¿⌈X¥¿₀Ḥ₉ỌŀoṆ~2JᶪNgWyZ∨ᵏᵘ#Ṡ=<W„J₀Ẇ

```

Try it Online!

90 'e's then the rest of the board as a string, split into chunks of 10

will try to do an algorithmic approach later

# Answer
> 1 votes
# Vyxal 3, 32 bytes

```
"ṁṘkƓ₳İᵛᵂƛ»Ω7∥I»;ᶤḌᶠĖꜝ“3y₅dÞ0₀Ẇ'

```

Try it Online!

This is roughly a port of Nick Kennedy's Jelly answer.

# Answer
> 1 votes
# 05AB1E, ~~34~~ 33 bytes

```
•{Žúƶ
Í‹¼šÎëPšpUθrćQ´β•3B¾94×ìTô»

```

~~Outputs `012` for `BEG`/blue-black-green respectively.~~
-1 byte thanks to *@noodleMan* by using `012` for `EGB`/black-green-blue instead.

Try it online.

**Explanation:**

```
•{Žúƶ
Í‹¼šÎëPšpUθrćQ´β•
            # Push compressed integer 166987503168216280220890692936947577852890694295235
 3B         # Convert it to base-3: 1100000000211000020022110002012221200000000000221022112222202201222222222120110222222211012112222202211122
   ¾94×     # Push a string of 94 "0"s
       ì    # Prepend it
        Tô  # Split it into parts of size 10
          » # Join this list by newlines
            # (after which the result is output implicitly)

```

See this 05AB1E tip of mine (section *How to compress large integers?*), to understand why `•{Žúƶ\nÍ‹¼šÎëPšpUθrćQ´β•` is `166987503168216280220890692936947577852890694295235`.

# Answer
> 1 votes
# Pascal (FPC), 232 bytes

On 6 June 1984, the first Tetris version was written in Pascal for the Electronica 60.

```
var i:Byte;begin for i:=1 to 9 do WriteLn('EEEEEEEEEE');WriteLn('EEEEGGEEEE'#10'EEEEBGGEEE'#10'EBEEBBGGEE'#10'EBEGBBBGBE'#10'EEEEEEEEEE'#10'BBGEBBGGBB'#10'BBBEBBEGBB'#10'BBBBBBBGBE'#10'GGEBBBBBBB'#10'GGEGBGGBBB'#10'BBEBBGGGBB');end.

```

Try it online!

**Challenge**

Can the code be modified to \< 200 bytes?

# Answer
> 1 votes
# Javascript (V8), 134 bytes

```
for(x of"@@@@@@@@@Ԁी@")print("0".repeat(10-(m=((v=x.codePointAt(0))<65?0:v).toString(4)).length)+m)

```

Try it online!

My first post! :3 Might as well start here because I'm a tetris fanatic

---
Tags: code-golf, ascii-art, kolmogorov-complexity
---


title: How many people are awake?

text:
# Question
Title: How many people are awake?
The following data contains the (approximate) population of each UTC timezone in the world (source):

```
UTC;Population (in thousands)
-11;57
-10;1853
-9.5;8
-9;639
-8;66121
-7;41542
-6;272974
-5;332101
-4.5;31923
-4;77707
-3.5;499
-3;248013
-2;4855
-1;3285
0;285534
+1;857443
+2;609921
+3;496279
+3.5;81889
+4;129089
+4.5;31042
+5;305642
+5.5;1458945
+6;199668
+6.5;50112
+7;439650
+8;1679526
+9;220112
+9.5;1814
+10;29482
+11;5267
+11.5;2
+12;6112
+13;308
+14;11

```

(for the sake of simplicity, I'm removing `+X.75` UTC times from the list)

Assuming that every person in the world wakes up at 8AM and goes to sleep at midnight (in their local time), how many people are simultaneously awake in the world at a given UTC time?

For example, suppose the given time is 2PM UTC. These are the timezones where the local time at 2PM UTC is between 8AM inclusive and midnight exclusive:

```
  -6 08:00 272974
  -5 09:00 332101
-4.5 09:30 31923
  -4 10:00 77707
-3.5 10:30 499
  -3 11:00 248013
  -2 12:00 4855
  -1 13:00 3285
  +0 14:00 285534
  +1 15:00 857443
  +2 16:00 609921
  +3 17:00 496279
+3.5 17:30 81889
  +4 18:00 129089
+4.5 18:30 31042
  +5 19:00 305642
+5.5 19:30 1458945
  +6 20:00 199668
+6.5 20:30 50112
  +7 21:00 439650
  +8 22:00 1679526
  +9 23:00 220112
+9.5 23:30 1814

```

Now, just add the population of these timezones and output 7818023 (corresponding to ~7.8 billion people).

## Input

An UTC time. You may accept two natural numbers ***h*** and ***m***, where ***0 ≤ h ≤ 23*** and ***m ∈ {0, 30}***.

Standard I/O applies, so you can accept them as lists, strings, etc. You can even accept ***m*** as a boolean value, where 0 means `HH:00` and 1 means `HH:30`.

There are two ways of solving this question: hardcoding the output (since there are only 48 possible inputs) or hardcoding the population data and solving by time arithmetic. However, to make this challenge more interesting, you are allowed to accept the population data as an additional input, so you don't need to hardcode it (thus saving you some bytes) and focusing only on the time arithmetic. So you can read it as additional lines from STDIN or an additional function argument.

## Output

How many people are awake at the given time, in thousands.

### Test cases

```
00:00 -> 3024211
00:30 -> 3024211
01:00 -> 3460576
01:30 -> 3510688
02:00 -> 3705501
02:30 -> 5164446
03:00 -> 5222075
03:30 -> 5252618
04:00 -> 5304000
04:30 -> 5353966
05:00 -> 5518144
05:30 -> 5518144
06:00 -> 5855091
06:30 -> 5855091
07:00 -> 6670992
07:30 -> 6670992
08:00 -> 6890405
08:30 -> 6890405
09:00 -> 6893051
09:30 -> 6893043
10:00 -> 6896034
10:30 -> 6896034
11:00 -> 7143682
11:30 -> 7144181
12:00 -> 7215776
12:30 -> 7247697
13:00 -> 7574531
13:30 -> 7574531
14:00 -> 7818023
14:30 -> 7816209
15:00 -> 7637639
15:30 -> 7637639
16:00 -> 6024234
16:30 -> 6024234
17:00 -> 5585223
17:30 -> 5535119
18:00 -> 5337315
18:30 -> 3878370
19:00 -> 3573093
19:30 -> 3542051
20:00 -> 3419074
20:30 -> 3337187
21:00 -> 2846175
21:30 -> 2846175
22:00 -> 2265736
22:30 -> 2267550
23:00 -> 1630219
23:30 -> 1630219

```

Try to make your code with the fewest bytes as possible.

---

Sandbox

# Answer
# Google Sheets, 38 bytes

```
=sumproduct(B:B,1/3<=mod(A:A/24+C1,1))

```

Paste UTC offset and population data in cells `A1:B`, put the time of the day in cell `C1`, and the formula in cell `D1`.

There was some confusion whether the expected results shown in the test cases were correct. The above formula matches the updated expected results.

Spreadsheet dateserials use a system where the duration of one day is 1. Eight hours, `8:00 am`, is one third of a day, i.e., `1/3`, and the value of 24 hours is exactly `1`. In spreadsheets, `mod()` always takes the sign of the divisor rather than that of the dividend which lets the formula wrap around midnight.

The rules allow some flexibility with input formats. If UTC offsets are input as durations like `-11:00`, `-10:00`, `-9:30` in column `A1:A`, they require no manipulation and can simply be added to the time of day (**35 bytes**):

```
=sumproduct(B:B,1/3<=mod(A:A+C1,1))

```
> 11 votes

# Answer
# Jelly, 11 bytes

```
ḅ.+%24>7.ḋ⁵

```

Try it online!

A full program taking three arguments (time as \[m/30, h\], timezones, populations) and printing the total population awake.

*Thanks to @JonathanAllan for saving two bytes and fixing a bug!*

## Explanation

```
ḅ.          | Base convert from base 0.5
  +         | Add timezones
   %24      | Mod 24
      >7.   | Greater than 7.5
         ḋ⁵ | Dot product with populations

```
> 6 votes

# Answer
# Charcoal, 21 bytes

```
ＩΣＥΦθ‹⁷·⁵﹪⁺⁺∕ζ⁶⁰ηκ²⁴ι

```

Attempt This Online! Link is to verbose version of code. Takes arguments in the order `zones`, `h`, `m`. Explanation:

```
    θ                   Input zones
   Φ                    Filtered where
      ⁷·⁵               Literal number `7.5`
     ‹                  Is less than
             ζ          Input minutes
            ∕           Divided by
              ⁶⁰        Literal integer `60`
           ⁺            Plus
                η       Input hours
          ⁺             Plus
                 κ      Current key
         ﹪              Modulo
                  ²⁴    Literal integer `24`
  Ｅ                     Map over entries
                    ι   Take the value
 Σ                      Take the sum
Ｉ                       Cast to string
                        Implicitly print

```

Python's `sum` sums the keys of a dictionary for some reason.
> 4 votes

# Answer
# JavaScript (Node.js), 48 bytes

```
c=>t=>c.map(([x,y])=>s+=(t+x+40)%24<16&&y,s=0)|s

```

Try it online!
> 3 votes

# Answer
# Funge-98, 126 bytes

```
"HTRF"4(0& 2*&+: 0'v00p
>&2*&+-: 0wv>&:bwv>     RR+'0%'`0w$:0
^$vvp16+'<> ^   > ^p10v'<>j#80:\+R<
$$<>   3j^ <^    >'>02p ^@.

```

Try it online!

First reads `h`, then `m` as 0 or 1, and finally each timezone as (`h`, `m`, `population`).

Contains a non-printable character, so here is a hex dump:

```
00000000: 2248 5452 4622 3428 3026 2032 2a26 2b3a  "HTRF"4(0& 2*&+:
00000010: 2030 2776 3030 700a 3e26 322a 262b 2d3a   0'v00p.>&2*&+-:
00000020: 2030 7776 3e26 3a62 7776 3e20 2020 2020   0wv>&:bwv>
00000030: 5252 2b27 3025 270f 6030 7724 3a30 0a5e  RR+'0%'.`0w$:0.^
00000040: 2476 7670 3136 2b27 3c3e 205e 2020 203e  $vvp16+'<> ^   >
00000050: 205e 7031 3076 273c 3e6a 2338 303a 5c2b   ^p10v'<>j#80:\+
00000060: 523c 0a24 243c 3e20 2020 336a 5e20 3c5e  R<.$$<>   3j^ <^
00000070: 2020 2020 3e27 3e30 3270 205e 402e           >'>02p ^@.

```
> 3 votes

# Answer
# Perl 5 List::Util, 65 bytes

```
sub{($t,%p)=map$_*2,@_;sum map$p{$_}/2*(($t+$_-16)%48<32),keys%p}

```

Try it online!
> 2 votes

# Answer
**T-SQL 64 Bytes**

```
declare @x table (utc int, pop int)
declare @t time(7)
insert @x values ...

```

`select sum(pop)from @x where datediff(h,utc,@t) between 8 and 24`
> 1 votes

---
Tags: code-golf, date
---