20
\$\begingroup\$

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

Blue Scuti

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  !! !!"""!!
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Put your challenges in Sandbox first unless you are sure there's no changes. \$\endgroup\$
    – qwr
    Jan 20 at 2:01
  • 12
    \$\begingroup\$ @qwr The whole point of the Sandbox is for other people to spot needed changes you missed/are unaware of. So please encorage poster to always use the Sandbox, regardless of what they're sure of. \$\endgroup\$
    – Noodle9
    Jan 20 at 12:29

25 Answers 25

10
\$\begingroup\$

C (gcc), 476 395 308 283 153 151 bytes

-130 bytes thanks to @Command Master
-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

cm

Linux Terminal

l_works_153

\$\endgroup\$
5
  • 2
    \$\begingroup\$ I think it's fine to have ANSI output, as adding your own restrictions on top of the challenge is OK, but there are a few trivial byte saves—you can use a single character instead of row, and there are many spaces you can remove \$\endgroup\$ Jan 20 at 3:55
  • 2
    \$\begingroup\$ 218 bytes \$\endgroup\$ Jan 20 at 6:53
  • \$\begingroup\$ Hopefully it's possible we can get it < 200 bytes? :) \$\endgroup\$
    – vengy
    Jan 20 at 12:05
  • \$\begingroup\$ 156 bytes (with colors!) \$\endgroup\$ Jan 21 at 5:09
  • 1
    \$\begingroup\$ 155 \$\endgroup\$ Jan 21 at 5:16
6
\$\begingroup\$

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

\$\endgroup\$
6
\$\begingroup\$

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.

\$\endgroup\$
6
\$\begingroup\$

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))
\$\endgroup\$
5
  • 1
    \$\begingroup\$ And it ends up not bad XD \$\endgroup\$
    – l4m2
    Jan 20 at 6:35
  • \$\begingroup\$ @l4m2 the constant is 175 bits, so 22 bytes of constant is a lower bound for this base-3 method without additional tricks. \$\endgroup\$
    – qwr
    Jan 20 at 7:00
  • \$\begingroup\$ Have you tried using a larger base? For instance base62 (26+26+10) or base 256 (an outright ascii string using ord)? Also, I wonder if numpy.base_repr or django.utils.baseconv.base62.decode could be useful, although that would be a different answer (under "python plus library" rather than just 'python') \$\endgroup\$
    – Stef
    Jan 21 at 16:25
  • 1
    \$\begingroup\$ @Stef base64 requires a library and python source files can't contain arbitrary bytes unless it's also Unicode (by default, maybe there is a python interpreter trick). I can read bytes from a file but I don't like doing that for codegolf answers. \$\endgroup\$
    – qwr
    Jan 21 at 18:58
  • \$\begingroup\$ *by Unicode I mean utf8 for python 3 \$\endgroup\$
    – qwr
    Jan 21 at 20:16
5
\$\begingroup\$

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
\$\endgroup\$
4
\$\begingroup\$

Charcoal, 37 35 bytes

GTχE⪪”{“⌈K→◧ψM^≡Nq§d5G↑℅a⁰≔)⦃L+y≡”χ

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

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

Perl 5, 108 bytes

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

Try it online!

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

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.

\$\endgroup\$
4
  • \$\begingroup\$ @vengy You're right, I made a small typo - 96 leading zeroes where there should have been 94. I just edited the post, it's fixed now. \$\endgroup\$
    – noodle man
    Jan 24 at 13:13
  • \$\begingroup\$ The rotate left 90 degrees (86 bytes) looks correct but it's flipped incorrectly. See my examples section for the correct orientation. It's tricky visualizing the rotated boards. ;) \$\endgroup\$
    – vengy
    Jan 24 at 13:26
  • \$\begingroup\$ @vengy Good catch, fortunately another easy fix - just had to reverse the array. \$\endgroup\$
    – noodle man
    Jan 24 at 16:40
  • \$\begingroup\$ Nice work. Thanks! \$\endgroup\$
    – vengy
    Jan 24 at 16:41
3
\$\begingroup\$

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!

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

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)
\$\endgroup\$
7
  • \$\begingroup\$ Nice. I'd like to see the output. Could you add a link such as Try It Online. To create your own demo, goto TIO, choose the Python language and cut N paste your code. Thanks! \$\endgroup\$
    – vengy
    Jan 31 at 14:06
  • \$\begingroup\$ @vengy Try it online!. Will edit into answer now. \$\endgroup\$
    – 00001H
    Jan 31 at 14:10
  • \$\begingroup\$ It's very close but the output screen needs to be flipped vertically. See one of the 90 degrees rotation examples in the challenge. \$\endgroup\$
    – vengy
    Jan 31 at 14:14
  • \$\begingroup\$ @vengy Fixed. Apparently it became shorter?? \$\endgroup\$
    – 00001H
    Jan 31 at 14:18
  • \$\begingroup\$ Did you update the link? I'm seeing the old output. \$\endgroup\$
    – vengy
    Jan 31 at 14:20
2
\$\begingroup\$

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.

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

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!

\$\endgroup\$
1
  • \$\begingroup\$ Designating empty blocks as 0 is a nice touch. Some solutions are using 1 which kinda triggers me. ;) \$\endgroup\$
    – vengy
    Jan 20 at 12:15
2
\$\begingroup\$

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
\$\endgroup\$
2
\$\begingroup\$

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

\$\endgroup\$
2
  • \$\begingroup\$ I cannot conceive of APL not being an elaborate practical joke that just went a bit too far. It's a cool language, but the typographic presentation is just a nasty-looking string :( \$\endgroup\$ Jan 21 at 17:19
  • \$\begingroup\$ @Kubahasn'tforgottenMonica Imagine you've never looked at an arithmetic expression before. Those +'s and -'s are probably pretty nasty-looking too. Of course, you learn arithmetic and then it becomes second nature. If you only speak English and you look at something written in Chinese, just because Chinese is foreign to your eyes doesn't mean it's 'nasty'. Same goes for APL vs. more common programming languages—when you learn APL, there's nothing nasty about it. Sorry if this comes off as aggressive, I don't mean it that way :) \$\endgroup\$
    – noodle man
    Jan 22 at 6:35
2
\$\begingroup\$

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.

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

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

▓▓░░░▓▓█▓▓
▓▓▓░░▓░█░░
▓▓▓▓▓▓▓█░░
█▓░▓▓▓▓▓▓▓
▓▓░█▓▓█▓▓▓
▓▓░░▓▓█░▓▓
██████████
█▓░▓▓▓░█▓█
██░░▓▓██▓█
███░░▓████
████░░████
██████████
██████████
██████████
██████████
██████████
██████████
██████████
██████████
██████████
\$\endgroup\$
2
  • \$\begingroup\$ 229 bytes to decode a 200 character grid? \$\endgroup\$
    – qwr
    Jan 20 at 2:03
  • \$\begingroup\$ @qwr 220 chars+23 (docstring + print)=243 chars required undecoded \$\endgroup\$
    – Joao-3
    Jan 22 at 19:04
2
\$\begingroup\$

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.

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

JavaScript (Node.js), 159 156 153 bytes

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

Try it online!

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Is that a RLE? Nice \$\endgroup\$
    – qwr
    Jan 20 at 6:13
  • 1
    \$\begingroup\$ yep, TIL that's what they're called \$\endgroup\$
    – mekb
    Jan 20 at 6:14
  • 3
    \$\begingroup\$ Impressive to implement it without knowing what it's called! \$\endgroup\$
    – qwr
    Jan 20 at 6:16
  • 1
    \$\begingroup\$ You can match \d+ instead of \d* to obviate the need for handling 1 as a special case for 153 bytes. \$\endgroup\$ Jan 20 at 19:43
2
\$\begingroup\$

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

\$\endgroup\$
3
  • \$\begingroup\$ @vengy oh my! ill fix that now \$\endgroup\$ Feb 8 at 13:43
  • \$\begingroup\$ @vengy it has been fixed , \$\endgroup\$ Feb 8 at 13:46
  • \$\begingroup\$ Tetris for @madeforlosers! \$\endgroup\$
    – vengy
    Feb 8 at 13:47
1
\$\begingroup\$

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.

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

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

\$\endgroup\$
1
  • \$\begingroup\$ Ruby’s just a byte longer than Vyxal?? :p \$\endgroup\$
    – noodle man
    Jan 22 at 15:17
1
\$\begingroup\$

Vyxal 3, 32 bytes

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

Try it Online!

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

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

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?

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

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.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Alternative 34, maybe 33 if there's a 1-char that can push 0? Try it online! \$\endgroup\$
    – noodle man
    Jan 26 at 18:16
  • \$\begingroup\$ @noodleman Thanks. And ¾ is 0 by default, as well as N outside of loops. Although in this case, the 0 94 could also be 0₃<. :) \$\endgroup\$ Jan 26 at 23:32
  • 1
    \$\begingroup\$ Cool, never used 05AB1E before but seems pretty easy to pick up coming from other stack-based languages. (The program I posted was just copy-pasting parts of your explanation, but using the integer from my Vyxal and Nick Kennedy's Jelly) \$\endgroup\$
    – noodle man
    Jan 26 at 23:33
  • \$\begingroup\$ @noodleman Yeah, 05AB1E isn't too hard to start with when you're familiar with stack-based languages. Of course, little tricks and golfing tips will come with experience, but feel free to make some 05AB1E answers and perhaps I can find something to golf further. (Or perhaps you find something more to golf in my answers like this one. ;D) \$\endgroup\$ Jan 26 at 23:39
1
\$\begingroup\$

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

\$\endgroup\$
1
  • \$\begingroup\$ Tetris for @madeforlosers! Looks good, nice work. \$\endgroup\$
    – vengy
    Feb 6 at 20:32

Your Answer

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

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