28
\$\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\$
  • \$\begingroup\$ Can there be some spaces on the <blank line>? \$\endgroup\$ – Jakube Sep 6 '15 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 Sep 6 '15 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\$ – trichoplax Sep 6 '15 at 11:40
  • \$\begingroup\$ @Jakube yes there can be spaces. \$\endgroup\$ – bitsnbites Sep 6 '15 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 Sep 6 '15 at 12:33

23 Answers 23

29
\$\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\$
  • 36
    \$\begingroup\$ +1 just for Calculate the factorial of 60,000 and discard the result. This takes "about a second". ;) \$\endgroup\$ – ETHproductions Sep 6 '15 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 Oct 17 '15 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 Oct 17 '15 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\$
  • \$\begingroup\$ use .V0 as infinite loop \$\endgroup\$ – Jakube Sep 6 '15 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\$ – trichoplax Sep 6 '15 at 14:05
  • \$\begingroup\$ @Jakube that does not seem to save anything. \$\endgroup\$ – Maltysen Sep 6 '15 at 17:01
  • \$\begingroup\$ You explanation doesn't correspond to your code :P \$\endgroup\$ – Beta Decay Sep 7 '15 at 7:18
9
\$\begingroup\$

QBasic, 58 bytes

Tested on QB64.

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 3 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\$
  • 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\$ – trichoplax Sep 6 '15 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\$
  • 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 Sep 6 '15 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 Sep 8 '15 at 6:35
  • \$\begingroup\$ @Dennis of course, because "\e" is just a shortcut for that anyway. Please, go ahead! \$\endgroup\$ – Dom Hastings Sep 8 '15 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\$
  • 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 Sep 6 '15 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 Sep 6 '15 at 3:12
  • 1
    \$\begingroup\$ Or, better yet, get rid of the HTML and replace document.getElementById`a` with document.body. \$\endgroup\$ – NinjaBearMonkey Sep 6 '15 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\$ – NinjaBearMonkey Sep 6 '15 at 14:56
  • 1
    \$\begingroup\$ This has stopped working for me on Chrome \$\endgroup\$ – Beta Decay Sep 6 '15 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\$
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\$
  • 1
    \$\begingroup\$ Does sleep measure intervals of three seconds? \$\endgroup\$ – trichoplax Sep 6 '15 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 Sep 6 '15 at 12:20
  • \$\begingroup\$ I don't know awk but it seemed likely it would measure in seconds. :) \$\endgroup\$ – trichoplax Sep 6 '15 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 Sep 6 '15 at 13:03
  • \$\begingroup\$ the sleep command is not awk, it's bash, btw \$\endgroup\$ – Cabbie407 Sep 6 '15 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\$
  • 1
    \$\begingroup\$ But a bare timeout 1 will put a lot of unrequested output on the console \$\endgroup\$ – edc65 Sep 6 '15 at 13:47
  • \$\begingroup\$ True, I had extra output. Edited. \$\endgroup\$ – Peter Lenkefi Sep 6 '15 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 Sep 6 '15 at 16:58
  • \$\begingroup\$ @edc65 The backdraws of copy-paste and not testing. Thank you! \$\endgroup\$ – Peter Lenkefi Sep 6 '15 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\$
  • \$\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\$ – trichoplax Sep 6 '15 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\$ – AdmBorkBork Sep 8 '15 at 18:14
  • \$\begingroup\$ golfed off 12 bytes thanks to TimmyD \$\endgroup\$ – Max Sep 10 '15 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\$
  • \$\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\$ – trichoplax Sep 6 '15 at 14:09
  • \$\begingroup\$ This doesn't produce the first animation frame (i.e., where the arms are level). \$\endgroup\$ – Psychonaut Oct 16 '15 at 11:44
  • \$\begingroup\$ you're right... I'm going to fix it! \$\endgroup\$ – Max Oct 16 '15 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\$
  • \$\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\$ – undergroundmonorail Sep 6 '15 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 Sep 6 '15 at 9:40
  • \$\begingroup\$ @GlenO On Windows cls works (see my answer) \$\endgroup\$ – Beta Decay Sep 6 '15 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\$
  • \$\begingroup\$ Love it! I notice via this that Chrome is executing ES6 for me now as well! \$\endgroup\$ – Dom Hastings Sep 8 '15 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\$ – ETHproductions Sep 8 '15 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\$
  • \$\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\$ – ETHproductions Sep 18 '15 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 Sep 19 '15 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\$ – ETHproductions Sep 20 '15 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 Sep 21 '15 at 4:00
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\$

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\$
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\$

Deadfish, Non-Competing (658 bytes)

iiisisdddddoiiiiiiiiiiiiiiiioddddddddddddddddodddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddoddddsddddoiiiiiiiiiiiiiiiioddddddddddddddddoddddddddddddddddddddddodddsddodddddddddddddddoddddddddddddddddddddddsddddddddoddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddoosddddddddoiiiiiiiiiiiiiiiiiiioddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddodddddddddddddddddddddddddddddddddddddosdddddodddddddddddddddddddddddddddddddddddddddddddddddoddddddddddddddddddddddddddddddddddddddsdddddodddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddoo

This a non-competing solution, as it does not completely meet the challenge requirements. Deadfish is a very strange interpretted lanugage, which only has 4 commands and an accumulator. The accumulator is a single byte variable initialized at 0. The 4 commands are:

  • i = Increment the accumulator a = a + 1
  • d = Decrement the accumulator a = a - 1
  • s = Square the accumulator a = a * a
  • o = Output the accumulator print(a)

As the language does not include repetition, clearing the screen, or delays, it does not meet the requirements. Expected output:

_o_
 0 
/ \
(Blank line, not from the program)
\o/
_0_
(Blank line, not from the program)
(Blank line, not from the program)

Code explanation:

_  iiisisdddddo
o  iiiiiiiiiiiiiiiio
_  ddddddddddddddddo
\n dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddo
   ddddsddddo
0  iiiiiiiiiiiiiiiio
   ddddddddddddddddo
\n ddddddddddddddddddddddo
/  dddsddo
   dddddddddddddddo
\  ddddddddddddddddddddddsddddddddo
\n ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddo
\n o
\  sddddddddo
o  iiiiiiiiiiiiiiiiiiio
/  ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddo
\n dddddddddddddddddddddddddddddddddddddo
_  sdddddo
0  dddddddddddddddddddddddddddddddddddddddddddddddo
_  ddddddddddddddddddddddddddddddddddddddsdddddo
\n dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddo
\n o

Deadfish interpretter in Python 3:

c=input()
o=""
a=0
for p in range(0,len(c)):
    i=c[p]
    if i=="i":
        a += 1
    if i=="d":
        a+=-1
    if i=="s":
        a=a*a
    if i=="o":
        o+=chr(a)
print(o)
\$\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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.