31
\$\begingroup\$

This is my first challenge, so I'm keeping it fairly simple.

If you've ever typed telnet towel.blinkenlights.nl on your command line and pressed enter, you will have experienced the joy of asciimation. Asciimation is, quite simply, doing an animation with ascii art. Today we will be doing a very basic asciimation of a person doing jumping jacks.

There will be two ascii pictures that we will put together into one asciimation. Number 1:

_o_
 0
/ \

Number 2:

\o/
_0_
<blank line>

Note that the second one has a blank line at the end.

So your program should do these steps:

  1. Clear the console screen.
  2. Print the correct ascii art image.
  3. Set a flag or something so you know to do the other image next time.
  4. Wait a moment (about a second).
  5. Continue at 1.

Rules

  • Your program must be a (theoretically) infinite loop.
  • The programming language you use must have been created before this challange was posted.
  • This is , so shortest code in bytes wins.
  • Standard loopholes apply.

Enjoy!

\$\endgroup\$
11
  • \$\begingroup\$ Can there be some spaces on the <blank line>? \$\endgroup\$
    – Jakube
    Commented Sep 6, 2015 at 5:44
  • 1
    \$\begingroup\$ Does this have to be platform independent because the Linux clear command (clear) is different to the Windows one (cls) \$\endgroup\$
    – Beta Decay
    Commented Sep 6, 2015 at 8:13
  • 1
    \$\begingroup\$ Is the blank line just to explain the positioning? If printing from the top of the screen so that the blank line makes no visible difference, can it be omitted? \$\endgroup\$ Commented Sep 6, 2015 at 11:40
  • \$\begingroup\$ @Jakube yes there can be spaces. \$\endgroup\$
    – bitsnbites
    Commented Sep 6, 2015 at 12:32
  • 1
    \$\begingroup\$ @trichoplax yes. The blank line is just to point out that the head must stay in the same position. \$\endgroup\$
    – bitsnbites
    Commented Sep 6, 2015 at 12:33

25 Answers 25

28
\$\begingroup\$

CJam, 51 45 42 38 36 bytes

"c\o/
_0_""^[c_o_
 0
/ \^["{_o\6e4m!}g

The above uses caret notation; the sequence ^[ is actually the ASCII character with code point 27.

I've borrowed the escape sequence (^[c) from @DomHastings' answer (with his permission) to save 4 bytes.

Verification

You can recreate the file like this:

base64 -d > jj.cjam <<< ImNcby8KXzBfIiIbY19vXwogMAovIFwbIntfb1w2ZTRtIX1n

To run the code, download the CJam interpreter and execute this:

java -jar cjam-0.6.5.jar jj.cjam

This will work on any terminal that supports console_codes or an appropriate subset.1

How it works

e# Push both jumping jacks on the stack.

"c\o/
_0_"

"^[c_o_
 0
/ \^["

e# When chained together, they contain two occurrences of the string "\ec",
e# which resets the terminal. Encoding the ESC byte in the second string
e# eliminates the need two escape a backslash before the string terminator.

{         e# Do:
  _o      e#   Copy the jumping jack on top of the stack and print the copy.
  \       e#   Swap the order of the jumping jacks.
  6e4m!   e#   Calculate the factorial of 60,000 and discard the result.
          e#   This takes "about a second".
}g        e# Since the discarded factorial was non-zero, repeat the loop.

1 The jumping jacks will look better if you hide the terminal's cursor before running the program. In Konsole, e.g., you can set the cursor's color to match the background color. This has to be done via your terminal's settings, since ^[c resets the terminal.

\$\endgroup\$
3
  • 37
    \$\begingroup\$ +1 just for Calculate the factorial of 60,000 and discard the result. This takes "about a second". ;) \$\endgroup\$ Commented Sep 6, 2015 at 2:39
  • \$\begingroup\$ Maybe 2Fm* is a good one-byte-shorter alternative to 6e4m! for "senseless operation that returns a truthy value and takes about a second to compute". \$\endgroup\$
    – lynn
    Commented Oct 17, 2015 at 20:42
  • \$\begingroup\$ @Mauris I had tried something similar with e!, but they seem to get memoized. After the first iteration, poor Jack gets a heart attack... \$\endgroup\$
    – Dennis
    Commented Oct 17, 2015 at 20:56
10
\$\begingroup\$

Pyth - 41 40 39 bytes

.VZ"\x1b[H\x1b[J"@c"_o_
 0
/ \\\o/
_0_"Tb .p9

(I'm counting the \x1b's as one byte since SO destroys special characters).

Clearly doesn't work online since its a) an infinite loop and b) uses terminal escape codes.

#                Infinite loop
 "..."           Print escape sequences to clear screen
 @               Modular indexing
  c     T        Chop at index ten into the constituent frames
   "..."         Frames 1 & 2 concatenated (Pyth allows literal newlines in strings)
  ~              Post assign. This is an assign that returns the old value.
   h             Increment function. Putting it after an assign makes it augmented assign.
   Z             Variable auto-initialized to zero.
 .p9             Permutations(range(9), 9). Takes about a second on my machine.

I was surprised to find out that augmented-assign worked with post-assign. Pyth is awesome.

\$\endgroup\$
4
  • \$\begingroup\$ use .V0 as infinite loop \$\endgroup\$
    – Jakube
    Commented Sep 6, 2015 at 6:11
  • \$\begingroup\$ You may be able to save a byte now that the OP has confirmed that the blank line doesn't need to be explicitly printed \$\endgroup\$ Commented Sep 6, 2015 at 14:05
  • \$\begingroup\$ @Jakube that does not seem to save anything. \$\endgroup\$
    – Maltysen
    Commented Sep 6, 2015 at 17:01
  • \$\begingroup\$ You explanation doesn't correspond to your code :P \$\endgroup\$
    – Beta Decay
    Commented Sep 7, 2015 at 7:18
9
\$\begingroup\$

QBasic, 58 54 bytes

Tested on QB64 and at Archive.org.

CLS
?"_o_
?0
?"/ \
SLEEP 1
CLS
?"\o/
?"_0_
SLEEP 1
RUN

The right language for the problem can be surprisingly competitive, even if it is usually verbose. The ? shortcut for PRINT helps too, of course. CLS is clear screen; RUN without arguments restarts the program, which is the shortest way to get an infinite loop.

The only other trick here is printing 0 for the midsection of the first picture. QBasic puts a space in front of (and after) nonnegative numeric values when it prints them, resulting in 0 . Saved 2 characters over " 0.

I may also point out that the delay in this code is literally a second, and is not machine-dependent. ;^P

\$\endgroup\$
1
  • 2
    \$\begingroup\$ I remember being annoyed by the surrounding spaces when printing numbers in various versions of BASIC. Nice to see there is a good use for it... \$\endgroup\$ Commented Sep 6, 2015 at 11:43
7
\$\begingroup\$

Perl (*nix), 54 bytes

sleep print"\x1bc",$-++%2?'\o/
_0_
':'_o_
 0
/ \
'while 1

(\x1b is counted as 1 byte but escaped for easier testing.) The above has been tested with Bash and shortened by another byte thanks to @Dennis!

Perl (Windows), 56 bytes

sleep print"\x1b[2J",$-++%2?'\o/
_0_
':'_o_
 0
/ \
'while 1

Thanks to @Jarmex for his testing and advice!

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Afraid that doesn't work on Windows, but you can get away only 1 byte more with: print"@[2J", replacing the @ inside the quotes with ASCII 27 (for testing purposes, print"\033[2J" might be easier). \$\endgroup\$
    – Jarmex
    Commented Sep 6, 2015 at 21:21
  • \$\begingroup\$ You can replace \e with a literal ESC byte. -- Would you mind if I use the \ec trick in my answer? \$\endgroup\$
    – Dennis
    Commented Sep 8, 2015 at 6:35
  • \$\begingroup\$ @Dennis of course, because "\e" is just a shortcut for that anyway. Please, go ahead! \$\endgroup\$ Commented Sep 8, 2015 at 8:19
6
\$\begingroup\$

Javascript (ES6), 109 93 79 70 bytes + HTML, 12 10 bytes = 120 106 91 80 bytes

Fairly straightforward. Uses template strings to store the images, and toggles a boolean value to determine which to use.

NOTE: This solution may not be valid, as it does not actually use a console. However, I don't believe it's possible to clear a browser console using JS, at least not while using Firefox.

a=!1,setInterval(_=>O.innerHTML=(a=!a)?`_o_ 
 0
/ \\`:`\\o/ 
_0_`,1e3)
<pre id=O>

\$\endgroup\$
21
  • 1
    \$\begingroup\$ @orlp Code creates the animated man. (Chrome @ Windows). This is GUI based rather than console based however. Might not be considered valid as such. \$\endgroup\$
    – Justin
    Commented Sep 6, 2015 at 3:12
  • 3
    \$\begingroup\$ 1. On my computer, this works fine in Firefox but not in Chrome, so I guess you should label it as ECMAScript 6 to avoid confusion. 2. If you put <pre id="a"/> in the HTML part, you don't need the <pre> tags in the code. \$\endgroup\$
    – Dennis
    Commented Sep 6, 2015 at 3:12
  • 1
    \$\begingroup\$ Or, better yet, get rid of the HTML and replace document.getElementById`a` with document.body. \$\endgroup\$ Commented Sep 6, 2015 at 3:29
  • 1
    \$\begingroup\$ I got 87 bytes by making the HTML <pre> and doing document.all[4]. This lets you get rid of the wrapper string and just make it innerHTML=a?`...`:`...`}. \$\endgroup\$ Commented Sep 6, 2015 at 14:56
  • 1
    \$\begingroup\$ This has stopped working for me on Chrome \$\endgroup\$
    – Beta Decay
    Commented Sep 6, 2015 at 17:03
5
\$\begingroup\$

Bash, 86 84 bytes

while sleep 1;do printf "\e[2J_o_\n 0\n/ \\";sleep 1;printf "\r\e[2J\o/\n_0_\n";done
\$\endgroup\$
4
\$\begingroup\$

Dash, 67 bytes

Also bash, ksh, zsh, ash, yash and probably many more besides. While it apparently works in these other shells, their own features and idiosyncrasies may allow for further golfing. I'll leave that as an exercise for the reader.

Notably not fish or tcsh.

f(){ clear;echo "$1";sleep 1;f "$2" "$1";};f '_o_
 0
/ \' '\o/
_0_'

Try it online! (with STDERR issue -- see Caveats)

Try it online! (with visible escape codes issue -- see Caveats)

How it works

Hopefully fairly self explanatory, even so:

Set up a function f which

  • Clears screen
  • Prints contents of $1
  • Sleeps 1 second
  • Calls f passing $1 and $2 in reverse order. This means the next iteration will display the "other" glyph before flipping them again... and so on.

Outside of the function is the initial call to f with literal depictions of the two character glyphs as two arguments.

Caveats

TIO's terminal implementation doesn't handle the clear well -- produces an error to STDOUT. If you add export TERM=vt100 as a header the error stops and it displays the literal escape string. This is a feature/limitation of TIO, not an issue with my submission. I've included links to both for reference. Code should work as intended in a "proper" terminal.

The recursion will eventually cause it to fail. Tried a soak test with sleep 0 in a Docker container and it threw a Segmentation Fault within a minute. Adding a trivial counter, which may or may not have quantum implications, it managed ~15000 iterations in my environment. So like 4 hours with the sleep -- and who's going to watch it that long? :-)

But I'd still argue that this complies with "theoretically" infinite, because it could go forever if it had "theoretically" infinite resources. That's my story and I'm sticking to it.

\$\endgroup\$
3
\$\begingroup\$

Python 2, 99 bytes

Runs on Windows

import os,time
g=0
while 1:os.system("cls");print["\\o/\n_0_","_o_\n 0 \n/ \\"][g];time.sleep(1);g=~g

For UNIX machines, add two bytes:

import os,time
g=0
while 1:os.system("clear");print["\\o/\n_0_","_o_\n 0 \n/ \\"][g];time.sleep(1);g=~g
\$\endgroup\$
3
\$\begingroup\$

awk - 95 92 86 84 83

END{
    for(;++j;)
        system("clear;printf '"(j%2?"_o_\n 0\n/ \\":"\\o/\n_0_")"';sleep 1")
}

Nice workout :D Just wondered if this was doable. No prices to gain though... ;)

If someone wants to test this: after you run the program you have to press Ctrl+D (end of input) to actually start the END block. To terminate it I have to use Ctrl+Z.

I also have this, which is only 74 bytes, but it starts with pausing a second which isn't the wanted behaviour I think

END{
    for(;1;print++j%2?"_o_\n 0\n/ \\":"\\o/\n_0_")
        system("sleep 1;clear")
}
\$\endgroup\$
5
  • 1
    \$\begingroup\$ Does sleep measure intervals of three seconds? \$\endgroup\$ Commented Sep 6, 2015 at 11:51
  • \$\begingroup\$ Oh my god. thanks for the hint :) Or if it wasn't a hint: No, this only slept 0.33 seconds. \$\endgroup\$
    – Cabbie407
    Commented Sep 6, 2015 at 12:20
  • \$\begingroup\$ I don't know awk but it seemed likely it would measure in seconds. :) \$\endgroup\$ Commented Sep 6, 2015 at 12:23
  • 1
    \$\begingroup\$ It just looks so more funny if it's moving faster, that I forgot about the golfing there ;D \$\endgroup\$
    – Cabbie407
    Commented Sep 6, 2015 at 13:03
  • \$\begingroup\$ the sleep command is not awk, it's bash, btw \$\endgroup\$
    – Cabbie407
    Commented Sep 6, 2015 at 13:28
2
\$\begingroup\$

Batch - 82 bytes

Edit: Muted the timeout command and removed the extra newline.

cls&echo _o_&echo  0&echo / \&timeout>nul 1&cls&echo \o/&echo _0_&timeout>nul 1&%0

I've seen 2 other similar batch answers so I didn't really want to post this, but this is my first ever golf.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ But a bare timeout 1 will put a lot of unrequested output on the console \$\endgroup\$
    – edc65
    Commented Sep 6, 2015 at 13:47
  • \$\begingroup\$ True, I had extra output. Edited. \$\endgroup\$ Commented Sep 6, 2015 at 15:17
  • 1
    \$\begingroup\$ maybe >mul it's type error, or maybe you don't know what nul is. en.wikipedia.org/wiki/Null_device \$\endgroup\$
    – edc65
    Commented Sep 6, 2015 at 16:58
  • \$\begingroup\$ @edc65 The backdraws of copy-paste and not testing. Thank you! \$\endgroup\$ Commented Sep 6, 2015 at 17:06
2
\$\begingroup\$

BBC BASIC, 75 bytes

Note that tokenisation pulls it down to 75 bytes. The whitespace is added in by the IDE.

      g=0
   10 IFg=0THENPRINT"\o/":PRINT"_0_"ELSEPRINT"_o_":PRINT" 0 ":PRINT"/ \"
      g=1-g:WAIT 100CLS:GOTO10

Properties showing program size

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

JavaScript ES6, 100 95 bytes

(f=_=>{console.log(_?`_o_
 0
/ \\`:`\\o/
_0_`)
(b=setTimeout)(q=>(clear(),b(b=>f(!_))),1e3)})()

Logs to the console. Tested on Safari Nightly

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

Batch, 151 130 118 bytes

cls
@echo _o_
@echo  0
@echo / \
@PING -n 2 127.0.0.1>NUL
cls
@echo \o/
@echo _0_
@PING -n 2 127.0.0.1>NUL
%0
\$\endgroup\$
3
  • \$\begingroup\$ You may be able to save a few bytes now that the OP has confirmed that the blank line doesn't need to be explicitly printed \$\endgroup\$ Commented Sep 6, 2015 at 15:02
  • \$\begingroup\$ You should be able to golf off 12 characters by using @PING 127.0.0.1 -n 2>NUL instead. Ping defaults to waiting about a second between attempts, so this is within a few milliseconds of being accurate, plenty close enough for this challenge. Reference \$\endgroup\$ Commented Sep 8, 2015 at 18:14
  • \$\begingroup\$ golfed off 12 bytes thanks to TimmyD \$\endgroup\$
    – Max
    Commented Sep 10, 2015 at 20:08
2
\$\begingroup\$

CBM 64 BASIC V2, 121 119 112 117 bytes

2?CHR$(147)+"\o/":?" 0":?"/ \"
3GOSUB7
4?CHR$(147)+"_o_":?"_0_"
5GOSUB7
6RUN
7A=TI
8IFTI-A<60THENGOTO8
9RETURN
\$\endgroup\$
3
  • \$\begingroup\$ Does ?CHR$(147) clear the screen? If so you may be able to save 2 bytes now that the OP has confirmed that the blank line doesn't need to be explicitly printed \$\endgroup\$ Commented Sep 6, 2015 at 14:09
  • \$\begingroup\$ This doesn't produce the first animation frame (i.e., where the arms are level). \$\endgroup\$
    – Psychonaut
    Commented Oct 16, 2015 at 11:44
  • \$\begingroup\$ you're right... I'm going to fix it! \$\endgroup\$
    – Max
    Commented Oct 16, 2015 at 12:21
1
\$\begingroup\$

Julia, 70 bytes

(on Windows, by replacing clear with cls, thanks to undergroundmonorail)

n(i=1)=(sleep(1);run(`cls`);print(i>0?"_o_
 0
/ \\":"\\o/
_0_");n(-i))

On Linux, 72 bytes

n(i=1)=(sleep(1);run(`clear`);print(i>0?"_o_
 0
/ \\":"\\o/
_0_");n(-i))

This uses actual newlines rather than \n to save a byte; otherwise, the i is either 1 or -1 as the "flag", and it uses recursion to achieve the infinite loop. Call it as either n(1) or just n().

Also, run(`clear`)/run(`cls`) uses a shell command to clear the window, because Julia doesn't have a built-in window-clear command.

\$\endgroup\$
3
  • \$\begingroup\$ If you run this on windows you save two bytes by changing clear to cls (I'm assuming, I don't know anything about Julia). \$\endgroup\$ Commented Sep 6, 2015 at 9:27
  • \$\begingroup\$ @undergroundmonorail - Thanks, but I use Ubuntu, cls doesn't work. Hopefully Julia decides to implement a real terminal-clearing function. \$\endgroup\$
    – Glen O
    Commented Sep 6, 2015 at 9:40
  • \$\begingroup\$ @GlenO On Windows cls works (see my answer) \$\endgroup\$
    – Beta Decay
    Commented Sep 6, 2015 at 10:05
1
\$\begingroup\$

Windows Batch, 83 89

Edit removed the empty line after the clarification by OP

@cls&echo _o_&echo  0&echo./ \&timeout>nul 1&cls&echo \o/&echo _0_&timeout>nul 1&%0

If you get rid of the empty line in the jumping man (that cannot be seen anyway), the score is 83

Note: timeout is not present in Windows XP. It works in Vista or newer versions. Moreover timeout is not precise to the second, so it's a perfect choice to implement step 4 (Wait a moment (about a second))

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

Javascript (ES6), 82 bytes

A modification of my previous answer that uses the console. Works partially in Firefox, but only clears the console in Chrome, AFAIK.

a=!0,c=console,setInterval(_=>c.log(c.clear(a=!a)|a?`_o_
 0
/ \\`:`\\o/
_0_`),1e3)

As always, suggestions welcome!

\$\endgroup\$
2
  • \$\begingroup\$ Love it! I notice via this that Chrome is executing ES6 for me now as well! \$\endgroup\$ Commented Sep 8, 2015 at 17:59
  • \$\begingroup\$ @DomHastings I've never developed in Chrome before, but I'd heard it didn't support ES6 by default, so I was just as surprised as you! :) \$\endgroup\$ Commented Sep 8, 2015 at 18:00
1
\$\begingroup\$

JavaScript, 92 91 89 bytes

x=0;setInterval(function(){console.log("\033c"+["_o_\n 0\n/ \\","\\o/\n_0_"][x^=1])},1e3)
  • No ES6 features (but would be significantly shorter with them)
  • Works with Node.js on Linux (don't know about other environments)
  • Partially works in Chrome's console (c is shown instead of clearing the console, breaking the output)

Removing "\033c"+ from the above code, the following works in the browser, but doesn't clear the console.

x=0;setInterval(function(){console.log(["_o_\n 0\n/ \\","\\o/\n_0_"][x^=1])},1e3)

\$\endgroup\$
4
  • \$\begingroup\$ Impressive work! Using ES6 features, I get 77: x=0;setInterval(_=>console.log("\033c"+[`_o_<line break> 0<line break>/ \\`,`\\o/<line break>_0_`][x^=1]),1e3) For some reason, JS won't let me pass console.log as the function and the ASCII man as an extra param. \$\endgroup\$ Commented Sep 18, 2015 at 16:01
  • \$\begingroup\$ @ETHproductions Thanks! I thought about doing it in ES6, but having never used it and not having io.js installed I decided not to. As far as not being able to pass console.log to setInterval, the reason is that we're not passing the function, but calling it. It would be evaluated before setInterval was called, and since console.log doesn't return, it would essentially be passing undefined to setInterval. Make sense? And thanks for shortening it! \$\endgroup\$
    – Nateowami
    Commented Sep 19, 2015 at 13:35
  • \$\begingroup\$ I understand what you're saying, but according to this page, this code should work: x=0;setInterval(console.log,1e3,"\033c"+[_o_<line break> 0<line break>/ \`,\\o/<line break>_0_][x^=1])` In fact, it doesn't bring up an error if I replace console.log with alert. \$\endgroup\$ Commented Sep 20, 2015 at 17:31
  • \$\begingroup\$ Ah, I get what you're saying. I think the problem though is that we need to log something different each time, but "\033c"+[`_o_<line break> 0<line break>/ `,\\o/<line break>_0_`][x^=1] gets evaluated before the call to setInterval. \$\endgroup\$
    – Nateowami
    Commented Sep 21, 2015 at 4:00
1
\$\begingroup\$

CBM BASIC v2.0 (68 characters)

0?"S_o_q||0q||N M":goS1:?"SMoN":?"_0_":goS1:gO
1wA161,255,pE(161):reT

The above requires some explanation, since Stack Exchange markup doesn't properly represent PETSCII characters:

  • The program is shown here for convenience in lowercase, but can and should be entered and run in uppercase mode on a Commodore 64.
  • The first and third "S" characters are actually in reverse video, and produced by pressing the CLR key (SHIFT+HOME).
  • The "q" characters are actually in reverse video, and produced by pressing the down cursor (CRSR ⇓).
  • The "|" characters are actually in reverse video, and produced by pressing the left cursor (SHIFT+CRSR ⇒).
\$\endgroup\$
2
  • \$\begingroup\$ I will try it later. PETSCII always looks more beautiful than ASCII. \$\endgroup\$ Commented Jun 8, 2023 at 16:10
  • \$\begingroup\$ Very good, the WAIT is especially useful, here is a video about it from my favourite YouTube channel 8-BIT Show and Tell -> youtu.be/iQbBlH6tHkI \$\endgroup\$ Commented Jun 8, 2023 at 18:40
1
\$\begingroup\$

TI-Basic, 58 56 bytes

While 1
ClrHome
If not(Ans
Disp "_o_"," 0","/ \
If Ans
Disp "\o/","_0_"
not(Ans
If dim(rand(70
End

-2 bytes for assuming that the code is run on a fresh interpreter.

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

Ruby, 79 bytes

k=!0;loop{puts((k)?"\e[H\e[2J_o_\n 0\n/ \\":"\e[H\e[2J\\o/\n_0_");k=!k;sleep 1}

Requires escape codes.

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

Forth, 86 bytes

Requires GNU Forth for the escaped strings. To run in a non-GNU Forth, just change S\" to S", and the escaped characters won't print correctly.

: P PAGE TYPE CR 999 MS ;
: R BEGIN S\" \\o/\n_0_" P S\" _o_\n 0 \n/ \\" P 0 UNTIL ; R
\$\endgroup\$
0
\$\begingroup\$

beeswax, 119 113 bytes

ph0`J2[`}ghq'-<gh0N}`0`}gN`/o\`Ngh0`J`<
>g}`o`}N` `0>'d`0 `N`/ \`0hg>-'phg}`[2`b
dF1f+5~Zzf(.FP9f..F3_#     d   <

Explanation of the important parts of the program:

left to right  right to left

3FBf   or       fBF3          27       ASCII code for (esc)
3             [x,x,3]•        set lstack 1st to 3
 F            [3,3,3]•        set lstack to 1st
  B           [3,3,27]•       1st=1st^2nd
   f                          push lstack 1st on gstack
——————
9PF.(f   or    f(.FP9         102400   counter to roughly match a wait time
                                       of 1 s on my i5 2410M Laptop
9             [x,x,9]•        set lstack 1st to 9
 P            [x,x,10]•       increment 1st
  F           [10,10,10]•     set lstack to 1st
   .          [10,10,100]•    1st=1st*2nd
    (         [10,10,102400]• 1st=1st<<2nd (100<<10=102400, arithmetic shift left)
     f                        push lstack 1st on gstack
——————
zZ~5+f   or    f+5~Zz         95       ASCII for '_'
z             [0,0,0]•        initialize lstack to zero
 Z            [0,0,90]•       get value from relative coordinate (0,0),
                              which is the location of `Z` itself, ASCII(Z)=90
  ~           [0,90,0]•       flip 1st and 2nd lstack values
   5          [0,90,5]•       set lstack 1st to 5 
    +         [0,90,95]•      1st = 1st+2nd
     f                        push lstack 1st on gstack

The f’s push the values on the gstack (global stack) for later use. These values are accessed by the 0gh (or the mirrored hg0) and hg (gh) instructions. h rotates the gstack upwards, g reads the top value of gstack and pushes it onto the lstack (local stack) of the bee (instruction pointer).

}`o`}N` 0 `N`/ \`                      sequence to print the standing man

N`\o/`Ng}`0`}N                         sequence to print the jumping man

}`[2J`                        equivalent to the ANSI escape sequence (esc)[2J
                              to clear the screen
>-'p  or >-'q  or >  p        loop for counting down (wait 1 s)
d  <      b  <    d'-<

In-depth explanation follows later, if needed. Maybe with animation.

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

Noodel, noncompeting 24 bytes

Noncompeting because Noodel was born after the challenge was created:)

”ṛ|ọBCḊCBCḣ“\o/¶_0_ḷėçḍs

Try it:)

How it works

”ṛ|ọBCḊCBCḣ              # Creates a string that gets decompressed into "_o_¶¤0¤¶/¤\" and places it into the pipe.
           “\o/¶_0_      # Creates a string and places it into the pipe.
                   ḷ     # Unconditionally loop the code up to a new line or end of program.
                    ė    # Takes what is in the front of the pipe and puts it into the back.
                     ç   # Clears the screen and prints.
                      ḍs # Delays for one second.

There currently is not a version of Noodel that supports the syntax used in this challenge. Here is a version that does:

24 bytes

\o/¶_0_ _o_¶¤0¤¶/¤\ḷçėḍs

<div id="noodel" code="\o/¶_0_ _o_¶¤0¤¶/¤\ḷçėḍs" input="" cols="5" rows="5"></div>

<script src="https://tkellehe.github.io/noodel/noodel-latest.js"></script>
<script src="https://tkellehe.github.io/noodel/ppcg.min.js"></script>

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

Nim, 107 bytes

import os,terminal
var f=0
while 0<1:eraseScreen();sleep 999;echo ["_o_\n 0 \n/ \\","\\o/\n_0_\n"][f];f=1-f

Don't Try it online!

\$\endgroup\$

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.