Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Do you want to code a snowman?

Here is a simple ASCII art snowman:

_===_
(.,.)
( : )
( : )

Let's make him some friends. This will be the general pattern for our ASCII art snowpeople:

 HHHHH
 HHHHH
X(LNR)Y
X(TTT)Y
 (BBB)

The leading spaces and the parentheses are always the same for all snowpeople. The different letters represent sections of the pattern that can individually change. Each section has exactly four presets for what ASCII characters can fill it. By mixing and matching these presets for all eight sections, we can make a variety of snowpeople.

All Presets

(Notice that spaces are put on otherwise empty lines so the section shape is always correct.)

H is for Hat

  1. Straw Hat

     
    _===_
  2. Mexican Hat

     ___ 
    .....
    
  3. Fez

     _ 
     /_\ 
    
  4. Russian Hat

     ___ 
    (_*_)
    

N is for Nose/Mouth

  1. Normal ,

  2. Dot .

  3. Line _

  4. None

L is for Left Eye

  1. Dot .

  2. Bigger Dot o

  3. Biggest Dot O

  4. Closed -

R is for Right Eye

(Same list as left eye.)

X is for Left Arm

  1. Normal Arm

     
    <
  2. Upwards Arm

    \
     
  3. Downwards Arm

     
    /
  4. None

Y is for Right Arm

  1. Normal Arm

     
    >
  2. Upwards Arm

    /
     
  3. Downwards Arm

     
    \
  4. None

T is for Torso

  1. Buttons :

  2. Vest ] [

  3. Inward Arms > <

  4. None

B is for Base

  1. Buttons :

  2. Feet " "

  3. Flat ___

  4. None

Challenge

Write a program that takes in an eight character string (via stdin or command line) in the format HNLRXYTB, where each letter is a digit from 1 to 4 that denotes which preset to use for the corresponding section of the snowperson. Print the full snowperson to stdout.

For example, the input 11114411 is the snowman at the top of the page. (First 1: he has a straw hat, second 1: he has a normal nose, etc.)

Another example, the snowperson for input 33232124:

 _
 /_\
\(o_O)
 (] [)>
 ( )

Details

  • Any amounts and combinations of leading/trailing spaces and leading/trailing newlines are allowed as long as...

    • the snowperson has all their sections arranged correctly with respect to one another, and
    • there are never more than 64 total whitespace characters (the general pattern is only 7×5, so you probably won't hit this limit).

    You don't need to print rows/columns of the pattern if they only contain whitespace. e.g. the empty line of the straw hat is not required.

  • You must use the ordering of the parts as they are given above.

  • Instead of a program, you may write a function that takes the digit string as an argument. The output should be printed normally or returned as a string.

  • You may treat the input as an integer instead of a string if preferred.

Scoring

The shortest code in bytes wins.

Bonus question: Which of the 65536 distinct snowpeople is your favorite?

Answer*

Draft saved
Draft discarded
Cancel
5
  • \$\begingroup\$ -4, just enough to beat CJam! \$\endgroup\$ Commented Sep 11, 2019 at 15:15
  • 1
    \$\begingroup\$ Down to 122, and also closer to what you originally had. \$\endgroup\$ Commented Sep 11, 2019 at 15:38
  • \$\begingroup\$ @Grimy Your 122 byte version has a 0 between its eyes. :) \$\endgroup\$ Commented Sep 11, 2019 at 16:40
  • \$\begingroup\$ Just a base-12 encoding mistake, should be easy enough to fix! \$\endgroup\$ Commented Sep 11, 2019 at 16:45
  • \$\begingroup\$ @Grimy You're right. I didn't had a lot of time yesterday, but it's indeed a simple fix in the list. Thanks for the -6! :) \$\endgroup\$ Commented Sep 12, 2019 at 5:50

AltStyle によって変換されたページ (->オリジナル) /