Our classic snake has developed an inbalance of growth hormones. To make matters worse, his tail is frozen in place! Given directional input as specified in Figure 1
, write a program to determine where he will grow.
Figure 1. Directional input.
Program specifications
- Read the input character by character on
STDIN
. - After reading a character, output the snake to
STDOUT
. Please include a blank line in between each time you print a snake. - The snake consists of
<>v^
and a head. The head of the snake may be any round character of your choosing, such aso
,0
,O
, or☺
. - Any combination of
wasd
is valid for input. - Your program should not assume the input is within a certain length.
- The snake can pile on top of itself, overwriting
<>v^
. See examples for snake growing mechanics. - Trailing whitespace is okay, but your snake must look correct.
Scoring
This is code-golf. Your score is the number of characters in your program. Lowest score wins!
Example snakes:
Input: ddddssaassdddddww
Output:
>>>>v
v
v<< ☺
v ^
>>>>>^
Input: dddsssaaawww
Output:
☺>>v
^ v
^ v
^<<<
Input: dddsssdddddasddddwww
Output:
>>>v
v ☺
v ^
>>>>v< ^
>>>>^
Input: dddwwdddssssaaaaaaaaawww
Output:
>>>v
☺ ^ v
^ >>>^ v
^ v
^<<<<<<<<<
Input: ddddssssaawwddddd
Output:
>>>>v
v
>>>>>☺
^ v
^<<
Input: dddddssaawwwwddddd
Output:
>>>>>☺
^
>>>^>v
^ v
^<<
Input:
ddddaaaasssssdddddddddddwwwwwaaaasssssdddddddddddwwwwwwwwwwsssssaaaasssssdddddddwwwwwddddssaaaasssddddaaaassssssssssdddwwwwwwwddddswaaaassssddaasssaaaaaaaaaawwwwddddssssaaaaaaaaaaawwwwddddsssssssssaaaa
Output:
v
v
v
v
v
v<<<< v<<<< v<<<< >>>>v
v v ^ v ^ ^ v
v v ^ v ^ v<<<<
v v ^ v ^ v
v v ^ v ^ v
>>>>>>>>>>>>>>>>>>>>>v<<<<
v
v
v v<<<<
v v ^
v v
>>>>v >>>>v v v
^ v ^ v v v<<
^ v ^ v v v
^ v ^ v v v
^<<<v<<<<<<<<<<<<<
v
v
v
v
O<<<<