103 101 bytes
Try it here! (write in
n on the initial stack or you'll get an error)
I decided to take a stab at my challenge since there were no sub 100 bytes answers. Place
n on the stack and away you go! This reuses the
(") characters to save some bytes.
Here we store
(") for later usage.
< move the IP left
[3'(")' push '(")' to a new stack
D move back down to a clean stack
v move the IP down into "dance chooser"
This is frequently executed to select which type of dance we're going to generate.
x generate a 100ms dance or a 200ms dance
1 .5 jump to "200ms dance"
\ mirror IP into "100ms dance"
v above the
x and a
< to the right of it too. These make the
x get re-executed if it tries to move the IP in the wrong direction.
Generate 100ms dance
Here we generate and output one of the 100ms dance moves.
\ mirror the IP right
: copy n
43 C43C call "generate '^' or 'v'" twice
_ ignored mirror
do output a carriage return
o output the first hand of the bird
I:o@:o@:o@D select, copy, and output '(")'
o output the second hand of the bird
S sleep for previous n*100ms
\ mirror IP back to "dance chooser"
43C - Generate "^" or "v"
This is a simple function that generates "^" or "v" then returns. It works similarly to the dance chooser where it has instructions around
x to ensure the IP only moves left or right.
x generate "^" or "v"
R!"^" > push "^" to stack and return
R "v" push "v" to stack and return
Generate 200ms dance
This is another that begins with
x. It'll be separated into two sections:
<(")> and another
(>")> and <("<), because they're two distinct sections and
x is the only thing they share.
This basically does the beginning of the
generate 100ms dance routine, but populates the bird hands as
>< instead of a random
^v combo. It multiplies
n by two this time as well. This makes it all setup to utilise the
generate 100ms dance routine to output the entire bird and wait 200ms instead.
> move IP right
:2* copy n and do n*2
_ ignored mirror
"><" push "><" to stack
b2. jump to "output carriage return" in "generate 100ms dance"
This little explanation is about the
<("<) generation, though the
x can send the IP outside of it (explained below).
x move to "choose dance", generate (>")>, <("<), or <(")> (previous routine)
'>)">(' push '(>")>' to the stack
'<("<)' push '<("<)' to the stack
u O< ensure inner code block is always executed with IP moving left
od output carriage return
ooooo output bird
S*2: sleep for n*200ms
.02 jump to "dance chooser"