44
\$\begingroup\$

Choose a set of four bytes without replacement (i.e. no byte repeated), and not necessarily in any particular order, from any one of the following four sets:

  1. The characters of any one single-byte encoding
  2. The Unicode characters in the range 00–FF
  3. The signed decimal integers in the range −128–127
  4. The unsigned decimal integers in the range 0–255

The four values you chose (please state which they are) will be the valid inputs. You must pair each value with one of the below ASCII artworks.

Given (by any means) one of your four valid inputs, respond (by any means, even list of strings) with the corresponding ASCII art. Extra white-space is allowed on all sides, as long as the image is in there in one contiguous 2D area.

First byte:

     /\
    /  \
   |    |
   |    |
   |    |
   |____|
    \__/
    |  |
    |  |
    |  |
    |  |
 /\ |  | /\
/  \|  |/  \
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
|  ||  ||  |
AAAAAAAAAAAA

Second byte:

  /\
 /  \
|    |
|    |
|    |
|____|
 \__/
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 |  |
 AAAA

Third byte:

  /\
 /  \
|    |
|    |
|    |
|____|
 \__/
 |  |
 |  |
 |  |
 |__|
  /\

Fourth byte:

 db
_/\_
\__/
|  |
|  |
|  |
|__|
 /\

What's new about this ASCII art Kolmogorov complexity challenge?

  1. The ability to select valid inputs presents a new aspect to the challenge. The inputs are clearly too limited to encode the entire result, but can carry enough information to merit attention.

  2. The multiple possible outputs share a lot of structure, so reuse of code or sub-images is feasible both within each image and between images.

  3. There is enough duplication that even languages which are not well-geared towards challenges like this have a fair chance of being able to use clever code rather than just hard-coding strings extensively.

\$\endgroup\$
5
  • 2
    \$\begingroup\$ db sounds like an Aston Martin! AFAIK it's a Tesla Roadster. \$\endgroup\$ Feb 6, 2018 at 23:56
  • 1
    \$\begingroup\$ @LevelRiverSt Bowie, not Brown! \$\endgroup\$
    – Adám
    Feb 6, 2018 at 23:59
  • \$\begingroup\$ Is leading / trailing whitespace allowed, particularly on the left? \$\endgroup\$ Feb 7, 2018 at 0:12
  • \$\begingroup\$ @LevelRiverSt Thanks. I forgot to write it, though I did think of it. \$\endgroup\$
    – Adám
    Feb 7, 2018 at 0:14
  • 2
    \$\begingroup\$ Is this really animation? \$\endgroup\$ Feb 18, 2018 at 5:01

10 Answers 10

41
\$\begingroup\$

JavaScript (ES6), 247 bytes

RegPack'ed. Expects 0...3 as input.

n=>[...'BigFu!#?%$Rocket'].reduce((s,c)=>(x=s.split(c)).join(x.pop()),`oF#$!
FRFRFRF|??|$i$t$t$t$t%# t #
!t!BBB
uuceeeeeee%c%|?|
o#, db
_#_
iggg
|?|%#g|o|e%t%t%tkgttgttcu,o#%!
RRR|??|%ieF R|oo|
$
oo%
 ?__#/\\!/o\\uAAAAFo g
ti\\?/Bkkk`).split`,`[n]

Try it online!

\$\endgroup\$
5
  • 16
    \$\begingroup\$ BigFu!#?%$Rocket? But this is just Falcon Heavy! \$\endgroup\$
    – Adám
    Feb 7, 2018 at 6:25
  • 16
    \$\begingroup\$ @Adám That's right. But BFR.reduce() == FalconHeavy :p \$\endgroup\$
    – Arnauld
    Feb 7, 2018 at 12:48
  • \$\begingroup\$ This is genius. For a second I was like wait what, theres a javascript builtin for that?! Then I came to my senses... +1! \$\endgroup\$
    – vero
    Feb 8, 2018 at 9:32
  • \$\begingroup\$ Impressive as ever. \$\endgroup\$ Mar 2, 2018 at 19:27
  • \$\begingroup\$ "FRFRFRF" = "Fu!#?%$RocketFu!#?%$RocketFu!#?%$RocketFu!#" right? I love this answer more than anything lol. \$\endgroup\$ Jun 25, 2018 at 23:41
13
\$\begingroup\$

Charcoal, 67 bytes

NθF⁼³θ«PAA↑↑¹⁸↗²‖MM⁴±χ»¿θ«↙²↓⁴M↗__¶\_¶»↓d/_¶ _\↓×⁴∨›²θ⁶¿‹¹θAA↑¶/_‖M

Try it online! Link is to verbose version of code. Takes input as a number 3-0. Explanation:

Nθ

Input the number.

F⁼³θ«PAA↑↑¹⁸↗²‖MM⁴±χ»

If it is 3, draw half the booster, then mirror it, then move to the tip of the rocket.

¿θ«↙²↓⁴M↗__¶\_¶»

If it is not 0, draw the left half of the front fuel tank.

↓d/_¶ _\

But if it is 3, draw left half of the nose cone.

↓×⁴∨›²θ⁶

Draw the left side of the rocket.

¿‹¹θAA↑¶/_‖M

Draw the appropriate base of the rocket and then mirror to finish.

\$\endgroup\$
4
  • \$\begingroup\$ Did you create Charcoal just for this contest? \$\endgroup\$
    – nielsbot
    Feb 8, 2018 at 19:58
  • \$\begingroup\$ @nielsbot Charcoal is 7 months old (see commit log). \$\endgroup\$
    – phyrfox
    Feb 8, 2018 at 20:20
  • \$\begingroup\$ I was kidding. But I guess it raises the question: is it golfing if you create a language to solve the problem? Where's the boundary? \$\endgroup\$
    – nielsbot
    Feb 9, 2018 at 21:33
  • 1
    \$\begingroup\$ @nielsbot I think that counts as one of the standard loopholes. \$\endgroup\$
    – Neil
    Feb 9, 2018 at 23:36
7
\$\begingroup\$

Clean, 292 278 273 271 262 261 bytes

-5 bytes thanks to Adám

import StdEnv,Text
e=[k,k,k,"|__|",m]
l=repeatn
o="\\__/"
n="/  \\"
m="/\\"
u="|    |"
s="AAAA"
k="|  |"
?z=[m,n,u,u,u,"|____|",o:z]

\i=[cjustify 12[c\\c<-:q]\\q<-[?[k,k,k,k,m+" "+k+" "+m,n+k+n,k+k+k:l 18(k+k+k)]++[s+s+s],?(l 24k++[s]),?e,["db","_/\\_",o:e]]!!i]

Try it online!

A lambda function, mapping the Int values 0..3 to the images in the order listed in the OP.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ 287 \$\endgroup\$
    – Adám
    Feb 7, 2018 at 0:50
  • \$\begingroup\$ @Adám Thanks! I was able to apply that, but I only saw it after I'd shortened it further - still saves bytes though :) \$\endgroup\$
    – Οurous
    Feb 7, 2018 at 0:55
  • 1
    \$\begingroup\$ Uh, why are there two snippets? \$\endgroup\$ Feb 7, 2018 at 11:35
  • \$\begingroup\$ @EriktheOutgolfer the second one is the lambda. The first one is the code it depends on. I don't put them in the same snippet because I can't multiline an assignment into the snippet. \$\endgroup\$
    – Οurous
    Feb 7, 2018 at 19:13
5
\$\begingroup\$

Python 2, 292 290 284 282 281 bytes

i,j,d,e,x,y=input()," "," /\\ ","/  \\","|  |","\__/"
f=i<1
l,m,n,p,q,s=3*f*j,j*(i<3),d*f,e*f,x*f,j*(i>0)
print"\n".join(([l+j+d,l+j+e]+[l+"|    |"]*3+[l+"|____|",l+j+y],[" db\n_/\_",y])[i>2]+([l+j+x]*4+[n+s+x+n,p+s+x+p]+[q+s+x+q]*18+[s+"A"*(4,12)[f]],[m+x]*3+[m+"|__|",m+d])[i>1])

Try it online!

Takes an integer 0 to 3 as input and uses list indexing (1 or 0) to build each output.

-2 for an unneeded pair of brackets.

-6 by removing a variable assignment that was only used once.

-2 for another single use variable.

-1 with a tip from @Rod

\$\endgroup\$
2
  • 1
    \$\begingroup\$ The n, p and q variables are unnecessary too (-2 bytes each). " db" and "_/\_" will be joined with "\n" later, you can turn both into " db\n_/\_" to save another byte. You can (probably) move the +y, from each element, out of the list (and remove the const too) something like (...)[i>2]+["\__/"] \$\endgroup\$
    – Rod
    Feb 7, 2018 at 13:55
  • \$\begingroup\$ @Rod Thanks for the \n tip. I missed that one. Not sure about n,p and q though. They are used twice each, one each side of the main rocket to define whether the boosters are needed or not. Simailarly y in one case needs newline before it and in the other case some other characters. Could probably benefit from a complete rewrite to be honest. Feel free to take any ideas from it and use them to post your own answer. \$\endgroup\$
    – ElPedro
    Feb 7, 2018 at 19:00
5
\$\begingroup\$

Ruby, 234 212 205 bytes

->n{y=*"| "
h=%w{/ /\ }+["|  "]*3+%w{|__ \\_}+y*3
t=%w{|_ /}
[h+["| ","/\\ | ","/  \\| ",*["|  || "]*18,?A*6],h+y*21<<?A*2,h+t,%w{d _/ \\_}+y*3+t][n].map{|a|a.rjust(6," ")+a.reverse.tr("\\\\/d","/\\\\b")}}

Try it online!

Takes an integer 0-3. Builds an array of the left halves of each phase, indexes in, then pads and reflects each row. All padding is to the same width, so the latter phases have leading whitespace. Returns an array of strings.

-2 bytes: Declare y as an array right away instead of needing *[y] later.

-5 bytes: Replace x="\\" with t=%w{_| \\}.

-5 bytes: Less dereferencing, more array addition.

-1 bytes: h+y*21+[?A*2] -> h+y*21<<?A*2 in phase 1.

-3 bytes: The spec allows the omission of *$/ to join the result.

-4 bytes: ["b","\\_","_/"] -> %w{b \\_ _/} in phase 3.

-2 bytes: Use %w notation in the head array also.

-7 bytes: Use rjust instead of manual padding (this also means generating the left side and mirroring it, instead of starting with the right side)

Ungolfed:

->n{
  y=*"| "                                            # Same as y=[" |"]
  h=%w{/ /\ }+["|  "]*3+%w{|__ \\_}+y*3              # Head for phases 0-2
  t=%w{|_ /}                                         # Tail for phases 2,3
  [
    h+["| ","/\\ | ","/  \\| ",*["|  || "]*18,?A*6], # Phase 0
    h+y*21<<?A*2,                                    # Phase 1
    h+t,                                             # Phase 2
    %w{d _/ \\_}+y*3+t                               # Phase 3
  ][n].map{|a|                                       # Choose phase
    a.rjust(6," ") +                                 # Pad left to width 6
    a.reverse.tr("\\\\/d","/\\\\b")                  # Add mirror (right side)
  }
}
\$\endgroup\$
2
\$\begingroup\$

SOGL V0.12, 90 bytes

┐∙2╚;+ƨA+.1>?jj■|_ /√+}R
3<?'».1>⌡9R"    kΓC+SA}‘03ž}.‽'⁴R╬³2±6«ž}.3=?4R╬³"XƧ⁸│\׀2⁴‘4n10žP}╬³

Try it Here!

Inputs 0/1/2/3 correspondingly to the bytes 1/2/3/4

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

Red, 333 bytes

f: func[g][t:{    }b:{ /\ }c:{/  \}d:{   |}e:{|}j:{\__/}k:{|  |}a:{AAAA}h:[1[t b]1[t c]3[d t e]1[d{____}e]1[t j]]z:[3[t k]1[t{|__|}]1[t b]]r: func[w][foreach[i v]w[loop i[print rejoin v]]]switch g[1 do[r h r[4[t k]1[b k b]1[c k c]18[k k k]]r[1[a a a]]]2 do[r h r[24[t k]]r[1[t a]]]3 do[r h r z]4 do[r[1[t{ db}]1[t{_/\_}]1[t j]]r z]]]

Try it online!

Takes 1 - 4 as input

f: func [ g ] [
    t: {    }
    b: { /\ }
    c: {/  \}
    d: {   |}
    e: {|}
    j: {\__/}
    k: {|  |}
    a: {AAAA} 
    h: [1 [t b] 1 [t c] 3 [d t e] 1 [d {____} e ] 1 [t j]]
    z: [3 [t k] 1 [t {|__|}] 1 [t b]]
    r: func [ w ] [
        foreach [ i v ] w [
            loop i [print rejoin v]]]
    switch g [
        1 do [r h r [4 [t k] 1 [b k b] 1 [c k c] 18 [k k k]] r [1 [a a a]]]
        2 do [r h r [24 [t k]] r [1 [t a]]]
        3 do [r h r z]
        4 do [r [ 1 [t { db}] 1 [t {_/\_}] 1 [t j] ] r z]
    ]
]

Rebol, 258 bytes

I made an experiment with Rebol's compress function, compressing a string of all the 4 stages and printing the corresponding part of it after decompression:

f: func[n][o:[[1 374][374 196][570 74][644 37]]
b: decompress debase{eJzjUgAB/RguMKWgAGbUgDg1OFnxQABmKcTEx+uDGTVQOZwM/RgwA2QTyBYQG2wbiAHDw5vjiAS4IEEOCwGoWmQKGsaQAIYE4eAhqeMFSCICGZKSxBWvHxPPBVYKDzkoAVamHwMAjkWmoKkCAAA=}
repeat i o/(n)/2[prin b/(i + o/(n)/1)]]

 f 3
  /\
 /  \
|    |
|    |
|    |
|____|
 \__/
 |  |
 |  |
 |  |
 |__|
  /\
\$\endgroup\$
2
\$\begingroup\$

Ruby, 209 183 bytes

->n{z=[a=' /\\ ',b='/  \\']+['|    |']*3+%w{|____| \__/}+[c='|  |']*24+[?A*n]
n>4&&z[10..-n/6]=n>8?[c,a+c+a,b+c+b]+[c*3]*18:['|__|',a]
n==5&&z[0,6]=%w{db _/\_}
z.map{|i|i.center(12)}}

Try it online!

Required inputs as follows:

Centre core + upper stage + fairing: 4
As above + boosters : 12
Upper stage + fairing: 6
Upper stage without fairing 5

The idea is to take the centre core + upper stage + fairing as a default and modify it for the other outputs.

Commented

->n{
  #z = array of parts for centre core + upper stage + fairing, with n A's at the bottom
  z=[a=' /\\ ',b='/  \\']+['|    |']*3+%w{|____| \__/}+[c='|  |']*24+[?A*n]

  #if n not 4, z from element 10 to the last [10..-1] or last but one [10..-2] =
  n>4&&z[10..-n/6]=
    n>8?[c,a+c+a,b+c+b]+[c*3]*18:   #centre core + boosters#
    ['|__|',a]                      #upper stage engine
  n==5&&z[0,6]=%w{db _/\_}        #if n==5, replace first 6 elements with unfaired payload
  z.map{|i|i.center(12)}          #pad each element of array to 12 characters
}                                 #return array of strings (format allowed by question)
\$\endgroup\$
1
  • \$\begingroup\$ The first answer to make non-trivial use of the input! Very nice. \$\endgroup\$
    – benj2240
    Mar 2, 2018 at 19:33
1
\$\begingroup\$

Jstx, 124 bytes

↕t▌ÇÇÉÇ~éÇÇÇÇÇÇÇÉΘçK↑ε♀▄ü╙Çz⌡"#ße┐é+\òEhZ█╣S♪[ƒuø>!f♪K▌;0♂9☺}ås══½☻eP▌◙&£óZß:&╝af$V≈-wº[√D(♪╘Pφó√ò▲¶>å⌡◘├^∟z◘αßj◙÷»|æ⌠┼øk&£b

Explanation

↕t▌ÇÇÉÇ~éÇÇÇÇÇÇÇÉΘçK↑ε♀▄ü╙Çz⌡"#ße┐é+\òEhZ█╣S♪[ƒuø>!f♪K▌;0♂9☺}ås══½☻eP▌◙&£óZß:&╝af$V≈-wº[√D(♪╘Pφó√ò▲¶>å⌡◘├^∟z◘αßj◙÷»|æ⌠┼ # Push literal      /\\n    /  \\n   |    |\n   |    |\n   |    |\n   |____|\n    \__/\n    |  |\n    |  |\n    |  |\n    |  |\n /\ |  | /\\n/  \|  |/  \\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\n|  ||  ||  |\nAAAAAAAAAAAA0\n  /\\n /  \\n|    |\n|    |\n|    |\n|____|\n \__/\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n |  |\n AAAA0\n  /\\n /  \\n|    |\n|    |\n|    |\n|____|\n \__/\n |  |\n |  |\n |  |\n |__|\n  /\0\n db\n_/\_\n\__/\n|  |\n|  |\n|  |\n|__|\n /\
ø                                                                                                                       # Push literal 0
k                                                                                                                       # Push a list of strings obtained by splitting the second stack value with the first stack value.
&                                                                                                                       # Swap the top two stack values.
£b                                                                                                                      # Push the value in the list of the second stack value at the index of the first stack value.

Try it online!

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

C (clang), 421 408 bytes

r,d,i;f(t){char *s="    ",*e="\n",*l[]={" /\\ ","/  \\","|    |","|____|","\\__/","|  |","AAAA","|__|"," /\\ ","_/\\_","\n"," db","|  ||  ||  |"},*p[]={"VABU3C1DVE8FFF1G","VABU3C1DVE4F1RYAFAKBFBKZ9MM1YGGG","VABU3C1DVE3F1HI","VLJE3F1HI"},*a="",*b,*c=e,*q=p[t];for(r=1;d=*q++;r=(d/48&&57/d)?d-48:r,c=(d/89&&90/d)?e+90-d:c,a=(d/82&&86/d)?s+86-d:a)if(d/65&&77/d)for(b=l[d-65],i=0;i<r;i++)printf("%s%s%s",a,b,c);}

Try it online!

\$\endgroup\$
1

Your Answer

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

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