16
\$\begingroup\$

The 21 Hairstyles of the Apocalypse

Given a a list of numbers between 1 and 21 (or 0 and 20) output a "stitched together" drawing of the following faces (see rules for stitching information):

     ___           ,,,           ooo           ===           +++           ###          -*~*-     
    (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)     
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-

     ***           |||           _/7           )))           (((           xxx           @__      
    (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)     
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-

     ((_           >X<           '*`           ^^^           )|(           \|/           &&&      
    (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)     
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-

Each, unique face listed on a new-line (the # is the integer ID for the face):

     ___      
    (o o)     
ooO--(_)--Ooo #1

     ,,,      
    (o o)     
ooO--(_)--Ooo #2

     ooo      
    (o o)     
ooO--(_)--Ooo #3

     ===      
    (o o)     
ooO--(_)--Ooo #4

     +++      
    (o o)     
ooO--(_)--Ooo #5

     ###      
    (o o)     
ooO--(_)--Ooo #6

    -*~*-     
    (o o)     
ooO--(_)--Ooo #7

     ***      
    (o o)     
ooO--(_)--Ooo #8

     |||      
    (o o)     
ooO--(_)--Ooo #9

     _/7      
    (o o)     
ooO--(_)--Ooo #10

     )))      
    (o o)     
ooO--(_)--Ooo #11

     (((      
    (o o)     
ooO--(_)--Ooo #12

     xxx      
    (o o)     
ooO--(_)--Ooo #13

     @__      
    (o o)     
ooO--(_)--Ooo #14

     ((_      
    (o o)     
ooO--(_)--Ooo #15

     >X<      
    (o o)     
ooO--(_)--Ooo #16

     '*`      
    (o o)     
ooO--(_)--Ooo #17

     ^^^      
    (o o)     
ooO--(_)--Ooo #18

     )|(      
    (o o)     
ooO--(_)--Ooo #19

     \|/      
    (o o)     
ooO--(_)--Ooo #20

     &&&      
    (o o)     
ooO--(_)--Ooo #21

The face is as follows:

    hhhhh     
    (o o)     
ooO--(_)--OooS

Where h is the dynamic apocalyptic hairstyle and S is the potential stitching hyphen.


Examples

Input: [1,2,3,4,5]

Output:

     ___           ,,,           ooo           ===           +++      
    (o o)         (o o)         (o o)         (o o)         (o o)     
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-

Input: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]

Output:

     ___           ,,,           ooo           ===           +++           ###          -*~*-          ***           |||           _/7           )))           (((           xxx           @__           ((_           >X<           '*`           ^^^           )|(           \|/           &&&      
    (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)         (o o)     
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-

Input: ["Fraggle Rock"] / [22] / [-21041024] / [22,23,24,25,26]

Output: Nobody cares.


Input: [1,1,1,1]

Output:

     ___           ___           ___           ___      
    (o o)         (o o)         (o o)         (o o)     
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-

Rules

  • Preceeding and trailing newlines/spaces/hyphen are fine.
  • Faces can occur more than once in the input.
  • If there is an invalid number in the input you may have undefined behavior.
  • The stitching:
    • The stitched faces will be concatenated by a single hyphen on the bottom (3rd) line.
    • The faces will all be on a single line (unlike the first drawing).
  • Input can be 0 or 1 indexed, with 20 being the max for 0, 21 for 1.
  • This is , lowest byte-count wins.
\$\endgroup\$
  • 1
    \$\begingroup\$ Pretty similar: codegolf.stackexchange.com/q/34773/29750 \$\endgroup\$ – NinjaBearMonkey May 9 '18 at 23:32
  • 7
    \$\begingroup\$ Number 7 seems to violate the "face is as follows" part \$\endgroup\$ – boboquack May 10 '18 at 9:05
  • 10
    \$\begingroup\$ All your test cases include a trailing "stitching" hyphen, which seems to contradict the spec. \$\endgroup\$ – Shaggy May 10 '18 at 13:08
  • 3
    \$\begingroup\$ Kilroy was here. \$\endgroup\$ – msh210 May 11 '18 at 10:04
  • 2
    \$\begingroup\$ @MagicOctupusUrn, can you please address the issue of the trailing hyphens I raised above? \$\endgroup\$ – Shaggy May 11 '18 at 23:40

16 Answers 16

9
\$\begingroup\$

Japt -R, 122 117 113 110 109 107 105 104 103 102 100 99 bytes

1-indexed, with index wrapping. I've followed the spec here, which requires a hyphen between the last line of each face, rather than the test cases, which include a hyphen after the last line of each face.

[Umg"@__((_>X<'*`^^^)|(\\|/"i"&_,o=+#*|)(x"m³ ò3 i7"-*~"ê)iA"_/7")¡"(o o)"á"O--(_)--O"ûoDÃq-]ûD m¸

Try it

[                                             :Construct an array of 3 elements
Umg"@.../"i"&...x"m³ ò3 i7"-*~"ê)iA"_/7")     :FIRST ELEMENT (F)
U                                             :  Input array
 m                                            :  Map
  g                                           :    Index into
   "@.../"                                    :      Literal string
          i                                   :      Prepend
           "&...x"                            :        Literal string
                  m                           :        Map
                   ³                          :          Repeat 3 times
                     ò3                       :      Split into chucks of 3
                        i7                    :      Insert at 0-based index 7
                          "-*~"ê              :        "-*~" palindromised
                                )             :      End insert
                                 iA"_/7"      :      Insert "_/7" at index 10
                                        )     :  End map
¡"(o o)"Ã                                     :SECOND ELEMENT (S)
¡                                             :  Map input array
 "(o o)"                                      :    Literal string
        Ã                                     :  End map
¡"O...O"ûoDÃq-                                :THIRD ELEMENT (T)
¡                                             :  Map input array
 "O...O"                                      :    Literal string
        ûo                                    :    Centre pad with "o"
          D                                   :      To length 13
           Ã                                  :  End map
            q-                                :  Join with "-"
]                                             :End array
 ûD                                           :Centre pad each string in F & S to length 13 with spaces, does nothing to T as it will always be at least 13 characters long
    m                                         :Map
     ¸                                        :  Join F & S with spaces. Split T on spaces, creating a singleton array which gets cast back to a string on output
                                              :Implicit output, joined with newlines
\$\endgroup\$
  • 1
    \$\begingroup\$ Nice job getting it to 100. That char-mirror method that we've wanted would really come in handy here. \$\endgroup\$ – Oliver May 10 '18 at 22:35
  • \$\begingroup\$ Also, that wrapping of the & to take advantage of was genius. Especially since that made it 1-based. \$\endgroup\$ – Oliver May 10 '18 at 22:38
  • \$\begingroup\$ It was the other way 'round; I realised I could move the & there if I made it 1-based ;) Still feel there's more to golf here but it's late so it'll have to wait 'til tomorrow. \$\endgroup\$ – Shaggy May 10 '18 at 22:41
6
\$\begingroup\$

Python 2, 209 bytes

def f(a):s=t=u='\n';i=0;exec"s+=(\"_,o=+#-*|_)(x@(>'^)\\&_,o=+#**|/)(x_(X*^||&_,o=+#~*|7)(x__<`^(/&\"[a[i]::21]+'*-'*(a[i]==6)).center(14);t+='    (o o)     ';u+='ooO--(_)--Ooo-';i+=1;"*len(a);print s+t+u[:-1]

Try it online!

0-based indexing; nothing especially clever here, just data accessed via slicing and using exec instead of a loop.

\$\endgroup\$
  • \$\begingroup\$ 186 bytes \$\endgroup\$ – Lynn May 11 '18 at 12:11
6
\$\begingroup\$

Charcoal, 103 102 bytes

E²⪫Eθ⎇ι(o o)⪫ײ§ -⁼λ⁶§⪪”|″:αuxkτT↷K[ï�↔ς↨?◧BZ@C←↑⊞A⧴M✂↶ºKf÷H#S⦃J&≔⁰∧5À³≕r‹▷”³λ× ⁹M⁴←⪫EθooO--(_)--Ooo¦-

Try it online! Link is to verbose version of code. Explanation:

E²⪫Eθ

Loop over the input twice. Each result is then implicitly printed on its own line.

⎇ι(o o)

On the second loop, just generate the eyes.

⪫ײ§ -⁼λ⁶

Wrap hairstyle 6 in -s, other hairstyles in spaces.

§⪪”|″:αuxkτT↷K[ï�↔ς↨?◧BZ@C←↑⊞A⧴M✂↶ºKf÷H#S⦃J&≔⁰∧5À³≕r‹▷”³λ

Extract the three hairstyle characters from a compressed string.

× ⁹

Insert nine spaces between each hair or eyes.

M⁴←

Move 4 spaces left.

⪫EθooO--(_)--Ooo¦-

Print the rest of the faces, joined with a -.

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

R, 413 391 bytes

Thanks Giuseppe for 22 less bytes and getting this under 400 bytes.

function(s,n=length(s)){I=intToUtf8
U=utf8ToInt
R=rep
K=cat
a=U("_,o=+#^*|&)(x")
b=c("@__","((_",">X<","'*`","",")|(","\\|/","","-*~*-","_/7")
s[s==7]=22;s[s==10]=23;s[s==18]=7;s[s==21]=10
for(i in s)K(I(c(rep(32,4+(i!=22)),"if"(i<14,R(a[i],3),U(b[i-13])),R(32,5+(i!=22)))))
K("
",I(R(c(R(32,3),40,111,32,111,41,R(32,6)),n)),"
")
K(I(40+R(c(x<-c(71,71,39,5,5),0,55,1,rev(x),5),n)[-(14*n)]))}

Try it online!

\$\endgroup\$
  • \$\begingroup\$ you should probably alias utf8ToInt and intToUtf8 \$\endgroup\$ – Giuseppe May 10 '18 at 17:30
  • \$\begingroup\$ 391 bytes \$\endgroup\$ – Giuseppe May 10 '18 at 17:36
  • \$\begingroup\$ @Giuseppe good point! I am ashamed of my index swaps it is so costly. I will work on it. \$\endgroup\$ – JayCe May 10 '18 at 17:40
  • \$\begingroup\$ @JayCe You missed one more rep to shorten: for(i in s)K(I(c(rep<-- \$\endgroup\$ – Kirill L. May 17 '18 at 17:58
  • \$\begingroup\$ Thanks @KirillL. ! I'll make sure to include this when I finally have time to review this code. \$\endgroup\$ – JayCe May 17 '18 at 18:24
5
\$\begingroup\$

JavaScript (ES6), 200 199 bytes

Expects 1-indexed input.

a=>[1,0,2].map(y=>a.map(n=>s=y&2?'ooO--(_)--Ooo':`    ${p='( -'[y*n-7?y:2]}${"o o___,,,ooo===+++###*~****|||_/7)))(((xxx@__((_>X<'*`^^^)|(\\|/&&&".substr(y*n*3,3)}${y?p:')'}    `).join(s[3])).join`
`

Try it online!

Commented

a =>                              // given the input array a[]
  [1, 0, 2].map(y =>              // for each row y:
    a.map(n =>                    //   for each integer n in a[]:
      s =                         //     let s be the content of this row
        y & 2 ?                   //     if this is the 3rd row:
          'ooO--(_)--Ooo'         //       use a hardcoded string
        :                         //     else:
          `    ${                 //       append 4 spaces
            p = '( -'[            //       append and save in p:
              y * n - 7 ? y : 2   //         '(' if y = 0 (2nd row)
            ]                     //         ' ' if y = 1 and n != 7
          }${                     //         '-' if y = 1 and n = 7
            "o o___,,,ooo(...)"   //       append the middle pattern (NB: truncated string)
            .substr(y * n * 3, 3) //       which is always the eyes if y = 0
          }${                     //
            y ? p : ')'           //       append p for the 1st row or ')' for the 2nd row
          }    `                  //       append 4 spaces
    ).join(s[3])                  //   join with the 4th character of s (space or hyphen)
  ).join`\n`                      // join with line-feeds
\$\endgroup\$
4
\$\begingroup\$

Ruby, 164 bytes

->a{puts a.map{|i|j="_,o=+# *| )(x    ^  &"[i];(j<?!?%w{@__ ((_ >X< '*` -*~*- )|( \|/ _/7}[i%11-2]:j*3).center(14)}*"","    (o o)     "*k=a.size,"ooO--(_)--Ooo-"*k}

Zero indexed. Try it online!

All the difficult stuff happens on the top line.

"_,o=+# *| )(x ^ &" contains all the hairstyles with 3 identical characters, from which we select the ith character, j.

if j is not a space, the following expression returns 3 copies of the character. If it is a space, we select the correct hairstyle from between the %w{}. The "odd" hairstyles are numbers 6,9,13,14,15,16,18,19 and i%11-2 gives a perfect hash to 0..7

j<?!?%w{@__ ((_ >X< '*` -*~*- )|( \|/ _/7}[i%11-2]:j*3

All that remains is to pad to 14 spaces (centred) and print an appropriate number of middles/bottoms.

\$\endgroup\$
  • \$\begingroup\$ You can drop parentheses in center(14) \$\endgroup\$ – Kirill L. May 11 '18 at 13:24
2
\$\begingroup\$

Python 2, 204 bytes

i=input();l=len(i)
for l in[' '*4+' -'[x==6]+"_,o=+#**|_)(x@(>'^)\\&_,o=+#~*|/)(x_(X*^||&_,o=+#**|7)(x__<`^(/&"[x::21]+' -'[x==6]+' '*5for x in i],['    (o o)     ']*l,['ooO--(_)--Ooo-']*l:print''.join(l)

Try it online!

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

Java 8, 273 263 bytes

a->{String r[]={"","",""},s="    ",t="ooO--(_)--Ooo",u="(o o)";for(int i:a){r[0]+=s+(i==7?"-":" ")+"___,,,ooo===+++###*~****|||_/7)))(((xxx@__((_>X<'*`^^^)|(\\|/&&&".split("(?<=\\G...)")[i]+(i==7?"-":" ")+s+" ";r[1]+=s+u+s+" ";r[2]+=t+"-";}return t.join("\n",r);}

Try it online.

Explanation:

a->{                       // Method with integer-array parameter and String return-type
  String r[]={"","",""},   //  Result-String, starting at three empty rows
         s="    ",         //  Temp-String of four spaces for the first and second rows
         t="ooO--(_)--Ooo",//  Temp-String for the third row
         u="(o o)";        //  Temp-String for the second row
  for(int i:a){            //  Loop over the input-array
    r[0]+=                 //   Append to the first row:
          s                //    Four spaces
          +(i==7?          //    If the number is 7 (edge-case):
             "-"           //     Append "-"
            :              //    Else:
             " ")          //     Append a single space
          +"___,,,ooo===+++###*~****|||_/7)))(((xxx@__((_>X<'*`^^^)|(\\|/&&&".split("(?<=\\G...)")[i]
                           //    Append the correct hat based on `i`
          +(i==7?"-":" ")  //    If the number is 7, append "-" again, else a space
          +s+" ";          //    And append five spaces
    r[1]+=                 //   Append to the second row:
          s                //    Four spaces
          +u               //    The head
          +s+" ";          //    Five spaces
    r[2]+=                 //   Append to the third row:
          t                //    The hands and bodies
          +"-";}           //    And the stitch "-"
  return t.join("\n",r);}  //  Return the three rows as single newline delimited String
\$\endgroup\$
2
\$\begingroup\$

R, 247 242 bytes

function(a,n=length(a)){for(i in a)cat(format(h[i],,,,"c",14+!20-i))
cat("
","   (o o)     "*n,"
")
cat("ooO--(_)--Ooo"*n,sep="-")}
"*"=rep
h=readLines(,21)
___
,,,
ooo
===
+++
###
-*~*-
***
|||
_/7
)))
(((
xxx
@__
((_
>X<
'*`
^^^
)|(
\|/
&&&

Try it online!

Now, trying to bring R to a more manageable byte count...

Since doing character manipulations in R is so hopelessly verbose, I settled on listing all face and hairstyle patterns completely as is. For pretty-printing the hairstyles I use format function with justify="centre". Unfortunately, we need to use an extra padding character for i==20 because format calculates padding as if the backslash was escaped, like \\|/.

The current version does not use trailing hyphen.

Edit: Credit to JayCe for -2 and Giuseppe for -3 bytes.

\$\endgroup\$
  • \$\begingroup\$ Love your direct approach! I wasn't aware of justify="centre" I can probably reuse it. Minus two chars : "/"=rep \$\endgroup\$ – JayCe May 17 '18 at 18:39
  • \$\begingroup\$ another two bytes down: format(h[i],,,,"c",14+!20-i) \$\endgroup\$ – Giuseppe May 17 '18 at 19:38
  • \$\begingroup\$ @Giuseppe it's actually -3, so even better. @JayCe very nice, in fact we don't use multiplication either, so overriding * looks even better - now it resembles string * number operation common to many other languages! \$\endgroup\$ – Kirill L. May 18 '18 at 12:34
2
\$\begingroup\$

C! (C-Wow 1.1.0), 251 Bytes

(Requires arguments to be passed on program execution, space separated)

SS("     (o o)     \nooO--(_)--Ooo-",'\n') SS("___A,,,AoooA===A+++A###A-*~*-A***A|||A_/7A)))A(((AxxxA@__A((_A>X<A'*`A^^^A)|(A\\|/A&&&",'A') F(MR("0",A(0),"23"),W("?");E) I(AC,W("     ");RI(TN(A(i))+2);W("     ")); WL I(AC,W(RI(0))); WL I(AC,W(RI(1)));

Ungolfed version:

STRSPLIT("     (o o)     \nooO--(_)--Ooo-", '\n')
STRSPLIT("___A,,,AoooA===A+++A###A-*~*-A***A|||A_/7A)))A(((AxxxA@__A((_A>X<A'*`A^^^A)|(A\\|/A&&&", 'A')
IF(MATHRANGE("0", ARGS(0), "23"), PRINT("?"); E)
LOOP(ARGC, PRINT("     "); READI(TONUM(ARGS(i)) + 2); PRINT("     "));
PRINTL
LOOP(ARGC, PRINT(READI(0)));
PRINTL
LOOP(ARGC, PRINT(READI(1)));
\$\endgroup\$
1
\$\begingroup\$

Red, 333 319 bytes

func[x][h: copy[]i: 0
foreach[k l m]{___,,,ooo===+++###   ***|||_/7)))(((xxx@__((_>X<'*`^^^^^^)|(\|/&&&}[alter h
pad pad/left either 7 = i: i + 1["-*~*-"][rejoin[" "k l m" "]]9
14]foreach y x[prin h/(y)]print append/dup copy"^/"{    (o o)     }l: length? x
print take/part append/dup copy""{ooO--(_)--Ooo-}l 14 * l - 1]

Try it online!

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

Ruby, 163 bytes

->a{puts a.map{|i|(i==6?"-*~*-":i<9?"_,o=+#~*|"[i]*3:"_/7)))(((xxx@__((_>X<'*`^^^)|(\\|/&&&"[3*i-27,3]).center 14}*"","    (o o)     "*k=a.size,"ooO--(_)--Ooo-"*k}

Try it online!

0-indexed. I fiddled with Level River St's answer and found another approach to encode the hairstyles, apparently of similar golfiness. Here, we treat the "longest" 5-char haircut as a special case, trivial patterns in the first part of the list are encoded by 1 char each, and in the second part all 3-char patterns are listed literally, no matter - are those chars distinct or not. Finally comes the monkey-face boilerplate.

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

C (gcc), 210 212 bytes

-4 bytes thanks to ceilingcat. (It grew again when I fixed a bug that the original code had.)

Pretty straight-forward.

#define r(s)for(i=!puts("");i<n;printf(s,c,"___,,,ooo===+++###*~****|||_/7)))(((xxx@__((_>X<'*`^^^)|(\\|/&&&"+x*3,c=x^6?32:45,x=l[i++]));
x,c,i;f(l,n)int*l;{r("%5c%.3s%-6c")r("    (o o)     ")r("ooO--(_)--Ooo-")}

Try it online!

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

PowerShell, 187 171 bytes

-16 bytes thanks to mazzy

''+($args|%{($x=' '*4)+($y=' -'[$_-eq6])+("___,,,ooo===+++###*~****|||_/7)))(((xxx@__((_>X<'*``^^^)|(\|/&&&"|% s*g($_*3)3)+$y+$x;$z++})
"$x(o o)$x "*$z
"ooO--(_)--Ooo-"*$z

Try it online!

0-indexed, has a trailing hyphen.

Unrolled:

''+($args|%{
    ($x=' '*4) + ($y=' -'[$_-eq6]) + 
    ("___,,,ooo===+++###*~****|||_/7)))(((xxx@__((_>X<'*``^^^)|(\|/&&&"|% substring ($_*3) 3) +
    "$y$x ";
    $z++
    })
"$x(o o) $x"*$z
"ooO--(_)--Ooo-"*$z

Nothing too fancy. Only the first line has some decent logic in it. It indexes into the hair string by using the $current_entry_value*3 and scoops out that chunk by using substring, before joining all the chunks into one big line. Ran into the issue of ` escaping the next caret, leaving me wondering why I was getting an IndexOutOfBounds error but that's fixed. Now using a much better way to combine the first line.

195 Bytes to follow the spec of no leading/trailing hyphens

\$\endgroup\$
  • 1
    \$\begingroup\$ nice 7. you could save some bytes Try it online! \$\endgroup\$ – mazzy Jun 20 at 5:32
  • 1
    \$\begingroup\$ and some more Try it online! \$\endgroup\$ – mazzy Jun 20 at 5:43
1
\$\begingroup\$

Python 3, 240 bytes

h=[x*3for x in"_,o=+#*|)(x^&"]
for i,*l in(6,"-*~*-"),(9,"_/7"),(13,"@__","((_",">X<","'*`"),(18,")|(","\|/"):h[:i]+=l
*x,=map(int,input().split())
l=len(x)
p=print
p(*(h[i].center(13)for i in x))
p("    (o o)     "*l)
p("ooO--(_)--Ooo-"*l)

Try it online!

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

Runic Enchantments, 313 bytes

B6?>8b2*B0il2)?\B" "9a2*
{" ___ "D
{" ,,, "D
{" ooo "D
{" === "D
{" +++ "D
{" ### "D
{"-*~*-"D
{" *** "D
{" ||| "D
{" _/7 "D
{" ))) "D
{" ((( "D
{" xxx "D
{" @__ "D
{" ((_ "D
{" >X< "D
{" '*` "D
{" ^^^ "D
{" )|( "D
{" \|/ "D\
{" &&& "D{
{"    " LLRB͍!{
"-(_)--Ooo-"{*@\~4-:l͍e,:{$ak$"    (o o)     "{*$ak$"ooO-"

Try it online!

Reasonably compact in terms of compressing the strings and re-using segments where possible as well as using the input values as direct jump offsets when Branching.

If excess trailing space is allowed, this can be shortened by 2 bytes by omitting the 4- on the last line. +2 bytes for a 1- if the final - is intended to not be there (matching spec, violating examples).

The chunk, " (o o) " is annoying impossible to compress, as constructing it using things like " "4* ends up being exactly the same number of bytes.

Passing inputs >21 do fun things. E.g. a single 22 gives a close shave.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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