# Make a hammer animation

The goal is to make a two frame animation with ASCII art of a hammer smacking a table.

Trailing white-space is allowed and the frames need to repeat continuously. The program should iterate over both frames with a time of 0.5 seconds between frames.

Lowest byte count wins for each language!

Sample:

Animation Frames:

Frame 1:
-------------------
|                   |
|                   |
|                   |
-------------------
/  /
/  /
/  /
/  /
/  /
/  /
/  /
/  /
/  /
\ /

---------------------------
|                           |

Frame 2:

----------
|          |
|          |
|          |
--------------------------------------|          |
|                                      |          |
--------------------------------------|          |
|          |
|          |
|          |
----------
-------------------------------
|                                |

• Welcome to the site! This sounds like a good idea, but you need to be way more specific, and spell out what the anination should be like. See other challenges in the ascii-art or animation tags for reference Mar 11 '18 at 16:54
• @LuisMendo Is This Better?
– user78881
Mar 11 '18 at 17:23
• @PythonDude29 If the answer needs to be a program/function which takes a number (say 1/2 or 0/1) and produces the appropriate frame, then you need to state so. If frame 1 needs to be displayed and then exchanged for frame 2 after a predetermined time or event, you need to state so.
Mar 11 '18 at 17:29
• I'm not a fan of these line controllers—it is my understanding that languages like Charcoal don't operate that way. I'd refer to other ascii-art and kolmogorov-complexity questions. However, this challenge does now fall within this site's requirements (IMO), so I'm voting to reopen. Mar 11 '18 at 20:23
• Also please don't write in title case. Mar 12 '18 at 11:33

# Python 3, 337 331 319 bytes

-12 bytes thanks to Amphibological

import os,time
t,e,q,p='- \n|'
j=e+t*19+q
L=p+e*19+p+q
l=j+3*L+j
for i in range(9):l+=e*(9-i)+'/  /'+q
l+=' \\ /'+3*q+e*24+t*27+q+e*23+p+27*e+p+q
c=39*e
C=p+10*e+p+q
m=10*t+q
R=e+38*t+C
f=(c+C)*3
r=q+c+e+m+f+R+p+38*e+C+R+f+c+e+m+34*e+31*t+q+32*e+p+32*e+q
b=0
while 1:print([r,l][b]);time.sleep(.5);os.system('cls');b=~b


Try it online!

It uses 'cls', so will only work on Windows, use 'clear' for Linux with +2 bytes.

Will add a gif later.

• Nice! You could change r if b else l to [r,l][b] and import os\nimport time to import os,time to save some bytes. Jul 25 '18 at 0:11

## Perl 5, 391 355 293 286 296 bytes

Whack whack whack, golfing those chars off, down to 296 b :) .5s sleep as per the question specs.

This also requires perl -E

$r="| 19|n"x 3;$p="| 10|n";$R=" 39$p"x 3;$T=" -38$p";$t=" 40-10n";$m=" -19n$r -19n 9H 8H 7H 6H 5H 4H 3H 2H 2\\ /n3 24-27n 23| 27|n";$M="$t$R$T| 38$p$T$R$t 34-30n 33| 30|n";for($m){say"\033[2J";map{s:H:/  /n:;y!n!\n!;print$1x($2?$2:1)if/(\D+)(\d*)/}(split/(.\d*)/);($m,$M)=($M,$m);select$v,$V,$v,.5;redo}


# initial vars build strings that the print will understand later
$r="| 19|n"x 3;$p="| 10|n";
$R=" 39$p"x 3;
$T=" -38$p";
$t=" 40-10n"; # set$_ to first frame
$_=" -19n$r -19n 9H 8H 7H 6H 5H 4H 3H 2H 2\\ /n3 24-27n 23| 27|n";

# M is second frame
$M="$t$R$T| 38$p$T$R$t 34-30n 33| 30|n";

# main loop
{

# clear screen
say"\033[2J";

# or windows, -1b
# system"cls";

# start map...
map{

# sed replace H for /  /n
s:H:/  /n:;

# tr replace n for newline
y!n!\n!;

# parens around ?: necessary due to x operator precedence
# if/regex/ prints $1$2 times
print$1x($2?$2:1)if/(\D+)(\d*)/ # map runs on char followed by a number or not }(split/(.\d*)/); # rotate frames ($_,$M)=($M,$_); # sleep for 1 second would be shorter, but perl does # not deal with integer sleep without time::hires # sleep 1; # select for decimal second sleep select$v,$v,$v,.5;

# do the current block again
redo
}


GIF of original in action: https://i.imgur.com/w3e2JQS.gifv

• Welcome to PPCG! It's common courtesy to have a header with the language name and byte count. Hope you stick around!
– Jo King
Jul 24 '18 at 6:07
• Thanks, I missed adding the title the first time through. Jul 24 '18 at 6:31

# Python 3.6, 413 bytes

from os import*
from time import*
s,y=' -';b=y*19;d=b+b;f=y*10;i=y*26;g=s*9;c=s+g;h=s*26;j=s*32;a=c+g;e=a+a;p=print;k=f'\n|{a}|';t,v=system,sleep;z='cls'
while 1:
t(z);p(f' {b} {k*3}\n {b}')
for x in range(9):p(f'{g[x:]}/  /')
p(f' \\ /\n {a} {i}\n {a}|{h}|');v(1);t(z);p(f' {e} {f}')
for w in range(7):p(f' {e}|{c}|')if w!=3else p(f' {d}|{c}|\n|{e}|{c}|\n {d}|{c}|')
p(f' {e} {f}\n {j} {i}\n {j}|{h}|');v(1)


Doesn't work on TIO, so here's a GIF:

Not the prettiest thing in the world, but I'm pretty proud of it. Suggestions on golfing it further are welcome!

P.S.: I used a 1 second delay because it looked better to me, but you can replace 1 with .5 to change that, at +2 bytes.

P.P.S: This will only work on Windows, to try on Unix, change cls to clear at +2 bytes.

• That's as amazing how does it work how long did it take you
– user78881
Jul 20 '18 at 21:42
• @PythonDude29 thanks. It didn't take too long, maybe about 45 mins. It works mostly by substituting variables into strings with the new python f-strings. I'll post a more detailed explanation when I get a chance. Jul 20 '18 at 21:48
• Ok it's really cool
– user78881
Jul 20 '18 at 21:49
• @PythonDude29 thanks. I really appreciate it! Jul 20 '18 at 21:50