9
\$\begingroup\$

Keeping with a festive theme, print a carol singing angel with the shortest possible code. The angel is raising money for the homeless, so must be able to sing all three of the below songs available at request. To illustrate she can sing them, the title of the song must be placed within the speech bubble. This song title will be input by the user. Examples include:

  • Mother Mary
  • Jingle Bells
  • Silent Night

Input:

Title: 1 of the 3 songs.

Output:

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /              \
(           )  <                              
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \  
  ‘ – “ - ‘

Please paste the result of your singing angel along with the song: "Silent Night".

Speech Bubble Rules:

The speech bubble must always have a frame of 12 underscore lines long.

The title of the song must always start on the second line.

The title of the song must always start 3 underscore spaces inside the bubble.

                  123456789...
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Song      \
(           )  <     Title                     
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \  
  ‘ – “ - ‘

Examples below:

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Mother    \
(           )  <     Mary                     
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \  
  ‘ – “ - ‘

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Jingle    \
(           )  <     Bells                         
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \  
  ‘ – “ - ‘

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Silent    \
(           )  <     Night                         
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \  
  ‘ – “ - ‘
\$\endgroup\$
7
  • 1
    \$\begingroup\$ 1. The / and \ in your angel's skirt are asymmetrical. Is this intentional? 2. What is the purpose of showing the output, if it should be identical to the question? \$\endgroup\$ Commented Dec 17, 2016 at 14:57
  • 1
    \$\begingroup\$ If you want to be exact - 9 letters long, 2 words, but the focus is more on the three songs listed in the description as opposed to other song titles. \$\endgroup\$
    – Belfield
    Commented Dec 17, 2016 at 18:20
  • 1
    \$\begingroup\$ This isn't ASCII-art! `‘–“ are not ASCII-characters. Also, why do you have different types of dashes? \$\endgroup\$ Commented Dec 17, 2016 at 19:04
  • 3
    \$\begingroup\$ @StewieGriffin I would bet this was an unintended consequence of typing or pasting the text in an editor with a "smart quotes/dashes" feature. TextEdit on OS X is pathological about this. We regularly get questions on SO along the lines of, "Why doesn't puts “hello” work?" \$\endgroup\$
    – Jordan
    Commented Dec 17, 2016 at 20:16
  • 2
    \$\begingroup\$ Indeed it is @Jordan.... \$\endgroup\$
    – Belfield
    Commented Dec 17, 2016 at 21:00

6 Answers 6

3
\$\begingroup\$

JS (ES6), 328 330 bytes

a=(b,c)=>b.repeat(c);f=prompt().split(" ");if(f[1].length<5)f[1]+=" ";console.log(a(" ",18)+a("_",12)+`
(\\   ___   /)    /`+a(" ",12)+`\\
( \\ (‘o‘) / )   /    `+f[0]+`    \\
(`+a(" ",11)+`)  <     `+f[1]+a(" ",21)+`
 (  ‘> <’  )    \\`+a(" ",14)+`/
    /    \\       \\`+a("_",12)+`/
   /      \\  
  ‘ – “ - ‘`)
  • 1 helper function (a gets charcode (one char shorter) and repeats c times)
  • 1 variable for getting input via prompt() and doing a split to array
  • arguably abuses the special cases there but still does the job
  • I assumed the extra 21 spaces in the middle column were needed

a=(b,c)=>b.repeat(c);f=prompt().split(" ");if(f[1].length<5)f[1]+=" ";console.log(a(" ",18)+a("_",12)+`
(\\   ___   /)    /`+a(" ",12)+`\\
( \\ (‘o‘) / )   /    `+f[0]+`    \\
(`+a(" ",11)+`)  <     `+f[1]+a(" ",21)+`
 (  ‘> <’  )    \\`+a(" ",14)+`/
    /    \\       \\`+a("_",12)+`/
   /      \\  
  ‘ – “ - ‘`)

\$\endgroup\$
5
  • \$\begingroup\$ With UTF8 encoding, this is 344 bytes, not 328. What encoding did you use to count the bytes? \$\endgroup\$
    – smls
    Commented Dec 17, 2016 at 18:37
  • \$\begingroup\$ smls is correct; this is 328 chars, but 344 bytes. You can save 14 just by getting rid of String.fromCharCode and doing a=(b,c)=>b.repeat(c), then calling with an actual space or underscore each time \$\endgroup\$ Commented Dec 17, 2016 at 19:12
  • \$\begingroup\$ @ETHproductions, fixed. \$\endgroup\$ Commented Dec 17, 2016 at 19:25
  • \$\begingroup\$ @n4melyh4xor Is it okay to accept the song title in pre-split form, i.e. to implement the code as a lambda that takes two separate parameters for the two words? Or does the song title have to come in as one string, and the splitting be done as part of the code? (The Python 3.6 solutions does the former, and if you green-light it I'll use it to shorten my Perl 6 solution, too... :)) \$\endgroup\$
    – smls
    Commented Dec 17, 2016 at 20:25
  • \$\begingroup\$ @smls, I think it should be taken in as one string and then you can do whatever you want. \$\endgroup\$ Commented Dec 17, 2016 at 21:07
3
\$\begingroup\$

Python 3.5, 207 chars, 226 bytes

def f(s):a,b=s.split();u='_'*12;[print(' '*int(x)if x.isdigit()else x,end='')for x in"99"+u+"\n(\\3___3/)4/66\\\n( \\ (‘o‘) / )3/4"+a+"4\\\n(92)2<5"+b+"\n (2‘> <’2)4\\95/\n4/4\\7\\"+u+"/\n3/6\\\n2‘ – “ - ‘"]

Output:

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Jingle    \
(           )  <     Bells
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \
  ‘ – “ - ‘

Slightly ungolfed:

def angel(s):
    a, b = s.split()
    u = '_' * 12;
    out = "99" + u + "\n"
    out += "(\\3___3/)4/66\\\n"
    out += "( \\ (‘o‘) / )3/4" + a + "4\\\n"
    out += "(92)2<5" + b + "\n"
    out += " (2‘> <’2)4\\95/\n"
    out += "4/4\\7\\" + u + "/\n"
    out += "3/6\\\n"
    out += "2‘ – “ - ‘"
    [print(' '*int(x) if x.isdigit() else x, end='') for x in out]

It replaces numerical digits with the same number of spaces.

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

Python 3.6 - 286 241 224 bytes

def x(L):X,Y=L.split();E,D=' '*11,'_'*12;print(f"""{' '*18}{D} 
(\   ___   /)    /{E} \\
( \ (‘o‘) / )   /    {X+' '*(10-len(X))}\\
({E})  <     {Y}
 (  ‘> <’  )    \{E}   /
    /    \       \{D}/
   /      \ 
  ‘ – “ - ‘""")
Input:
x("Silent Night")
Output:    
                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Silent    \
(           )  <     Night
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \ 
  ‘ – “ - ‘

Note - The version is 3.6 where string literal formatting was introduced. Hence, this won't work in earlier versions.

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

PHP, 215 bytes

<?=($p=str_pad)($p($s=" ".$t="   ",18),30,_),$p("
(\   ___$t/)$s/",31),$p("\
( \ (‘o‘) / )$t/$t$argv[1]",37),"\
($s$s$t)  <$s$argv[2]",$p("
 (  ‘> <’  )$s\\",36),$p("/
$s/$s\\$s$t\\",32,_),"/
$t/$t$t\
  ‘ – “ - ‘";

takes title from first two command line arguments.

For Windows: add 1 to all pad-lengths after the first line, or duplicate backslashes before line breaks and replace all line breaks with \n

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

Perl 6, 234 bytes (218 characters)

{"{' 'x 18}{'_'x 12}
(\\   ___   /)    /{' 'x 12}\\
( \\ (‘o‘) / )   /    {.words[0].fmt('%-9s')} \\
({' 'x 11})  <     {.words[1]}
(  ‘> <’  )    \\{' 'x 14}/
    /    \\       \\{'_'x 12}/
  /      \\
  ‘ – “ - ‘"}

A lambda that inputs the song name as a string, and outputs the snow angle as a string.

  • Assumes that trailing spaces are not required.
  • Bytes count is for UTF8 encoding, because that's how Perl 6 expects source code.
\$\endgroup\$
1
\$\begingroup\$

Python 2.6, 391 bytes

def angel(a):
    X,Y=a.split()
    print("                  ____________")
    print"(\   ___   /)    /            \\"
    print"( \ (‘o‘) / )   /  ",  X,  "    \\"
    print"(           )  <   ", Y,        "  "
    print" (  ‘> <’  )    \              /"
    print"    /    \       \____________/"
    print("   /      \  ")
    print"  ‘ – 

Test Case:

angel("Silent Night")
                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /   Silent     \
(           )  <    Night   
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \  
  ‘ – “ - ‘
\$\endgroup\$
2
  • \$\begingroup\$ What´s the byte count? You may want to use #title instead of **title* \$\endgroup\$
    – Titus
    Commented Dec 20, 2016 at 0:34
  • \$\begingroup\$ Little late (OK, a lot late) but you can use 1 space for indentation to save a lot of bytes, and you can say p=print to shorten your prints \$\endgroup\$
    – Stephen
    Commented Jul 19, 2017 at 16:23

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.