| Bytes | Lang | Time | Link |
|---|---|---|---|
| 229 | AWK | 250410T185951Z | xrs |
| 5857 | MATL | 180125T225409Z | Luis Men |
| 281 | PowerShell | 210221T045943Z | wasif |
| 041 | Stax | 210220T081229Z | Razetime |
| 186 | Octave | 180127T134527Z | Sanchise |
| 173 | TIBASIC | 180127T200012Z | Weregoos |
| 169 | Ruby | 180126T195346Z | Håv |
| nan | JavaScript ES2017 + HTML | 180126T102523Z | Birjolax |
| 170 | Python 2 | 180126T143322Z | ovs |
| 294 | Clean | 180125T225425Z | Οurous |
| 053 | SOGL V0.12 | 180125T213931Z | dzaima |
AWK, 229 bytes
func l(){system("sleep .25")}func p(z){printf"\r"z (i%2?"8<":"8=")l()}{if($1>0)for(;i++<$1*2+1;s=s (i%2?X:"-"))p(s)
if(!$1)for(;i++<10;)p();if($1<0)for(i=(-$1)*2+1;i-->1;s=s (i%2?X:"-"))printf"\r%"(-$1+3)"s",(i%2?">8":"=8")s l()}
MATL, 59 58 57 bytes
|EQG~10*+:"&FXx45@q2/kGg*XHY"8Vh61@oGO<Eq*+h4M?G|H-Z"hP]D
Try it at MATL Online! Or see an example run from the offline compiler:
PowerShell, 281 bytes
$n=$args[0];$o="8<";$c="8=";function x{sleep .25};if($n-le0){$n=[math]::abs($n);$o=">8";$c="=8";$p=' '*$n;$p+$o;$x;$p+$c;1..$n|%{$p=$p-replace"\s$","";$p+$o+('-'*$_);if($_-eq$n){break};$x;$p+$c+('-'*$_)};$x}else{$o;x;$c;1..$n|%{
$y='-'*$_;$y+"8<";if($n-eq$_){break};$x;$y+"8=";$x}}
Stax, 46 41 bytes
üîφL↑≥ª⌡↨ÄA ¡`╢Σ·TmÄ↕=≈─Xí♫αF²M☻8]▒2±(═[3
|, was included in a recent release, which is great for this challenge!
Uses JS requestAnimationFrame for pausing between snips.
Each testcase happens continuously after the other, so if you want a more clear version, try this!.
-5 bytes from recursive. (:R)
Explanation
c|a^5?rFxs0?.<={n'-*'8+s+x|a^^(x0<{:R}M{|,}9*|:pF
c|a^5? initial zero check:
? if the input is truthy
|a^ take abs(n) and increment
5 otherwise push 5
r range 0..n-1
F for each value in the range,
xs0? r: if input is 0, then push 0, otherwise push loop iteration no.
.<={...Ffor each value in "<=",
n'_* repeat "_" r times
'8+ add 8 to that
s+ add current loop iteration to that
x|a^^ take abs(input) and increment twice
( pad on right to that length
x0<{...}M if input is less than 0
:R reflect the string (< → >)
{|,}9* delay 9 frames
|: output a form feed (clear screen)
p print the string without newline
Octave, 190 186 bytes
k=32+~e((a=abs(n=(z=input(''))+~z*10))+1,1);for i=1:a
clc
k(i:i+1)=[56,61-(s=sign(n))];q=@(m)fprintf(rot90([m ''],s));q(k)
if(i-a)pause(.25)
clc
k(i+1)+=s;q(k)
pause(.25);k(i)=45;end
end
Try it online! (note: clc does not work in TIO, so it's just all the animation frames outputted sequentially). Thanks for @LuisMendo for making me aware of the function e(...) in Octave, which is equal to exp(1)*ones(...).
It turns out that inline assignments return only the changed array entries, not the entire array. This means that constructions like q(k(i+1)+=s) are not possible, so the program is almost like MATLAB. In fact, the MATLAB entry is only slightly longer,
MATLAB, 198 195 bytes
n=input('');n=n+~n*10;a=abs(n);s=sign(n);k=zeros(a+1,1);q=@(k)fprintf(rot90([k ''],s));for i=1:a
k(i:i+1)=[56 61-s];clc
q(k)
if(i-a)pause(.25);
k(i+1)=k(i+1)+s;clc
q(k)
pause(.25)
k(i)=45;end
end
TI-BASIC, 173 bytes
:"-
:For(X,1,5
:Ans+Ans
:End
:For(X,1,32
:" "+Ans+" →Str1
:End
:ClrHome
:Input N
:N<0→X
:For(A,not(N),abs(N+5not(N
:For(B,4-3X,6-3X-(A=abs(N)),2
:33X-Anot(not(N
:Output(1,16,sub(Str1,33X+32,abs(Ans-1)-NX-31X)+sub(">8=8<8=",B,2)+sub(Str1,Ans+32,1
:rand(11
:End
:End
Having the 0 input terminate in a different frame from the others was a very interesting obstacle!
Since TI-BASIC doesn't like empty strings, this maintains at least one dummy character to the left of the scissors, the first of which is constantly a space; to hopefully avoid counting this as part of the n spaces for negative inputs, this program begins printing from the rightmost column of the first row, then wraps the remainder of the string downward in order to begin the actual field of animation there, fresh off the first column.
Some notes for an exotic device: TI-BASIC code size is measured in tokens, not characters. For consistent cross-calculator comparisons, we usually ignore byte counts dealing with header lengths (e.g., we subtract 8 from PROGRAM:SCISSORS). Additionally, for routines which are fully well-behaved on the home screen (those lacking in control structures, for the most part), we further eliminate the size of an empty program to "save" on 9 bytes as well. This program in particular is not typable on the home screen, so that liberty won't be taken.
Ruby, 169 bytes
->x{i="";o=?=;(x!=0&&x.abs*2+1||10).times{|l|o=o[?=]?x>0?"8<":">8":x>0?"8=":"=8";f=?\s*(x<0&&-x-l/2||0);system"cls";puts x>0?i+o:f+o+i;i+=?-if(l).odd?&&x!=0;sleep 0.25}}
Pretty much self explainatory when you dig into it, atleast in my opinion. Program has to be running on a computer with the cls command/alias.
Try it online! ( Had to overwrite the system() method, just for this script, due to the limitations mentioned above. )
I did try to use
puts `cls`, ...
But it just printed an invisible character, anyone know why?
JavaScript (ES2017) + HTML, 165 + 10 bytes
-16 bytes by @Shaggy
n=>(g=i=>i<-~(n?2*m:9)&&setTimeout(g,250,i+1,s=8+"<>="[i%2?2:n<0|0],o=("-".repeat(i/2)+s).padEnd(m+2),e.innerHTML=(n?n<0?[...o].reverse().join``:o:s)))(0,m=n<0?-n:n)
<pre id=e>
Try it in the below snippet:
let globalTimeout;
const _setTimeout = setTimeout;
window.setTimeout = function(){ globalTimeout = _setTimeout.apply(this, arguments); }
// Code above is to support user input
f=
n=>(g=i=>i<-~(n?2*m:9)&&setTimeout(g,250,i+1,s=8+"<>="[i%2?2:n<0|0],o=("-".repeat(i/2)+s).padEnd(m+2),e.textContent=(n?n<0?[...o].reverse().join``:o:s)))(0,m=n<0?-n:n)
// Code below is to support user input
f(10)
const $inp = document.getElementById("inp");
inp.addEventListener("change", ()=>{
clearTimeout(globalTimeout);
f(+inp.value);
});
<input type="number" id="inp" min="-31" max="31" value="10" />
<pre id=e>
Python 2, 170 bytes
import time
n=input()
a=abs(n);s=a and n/a
for i in range([a-~a,10][a<1]):print'\n'*30+(a-i/2)*-s*' '+i/2*s*'-'+'>='[i%2]*(s<1)+'8'+'<='[i%2]*s+i/2*-s*'-';time.sleep(.25)
Clean, 294 bytes
import StdEnv,System.Time,ArgEnv,System._Unsafe
Start#n=toInt(select(getCommandLine)1)
=[?k l\\k<-[1..]&l<-if(n==0)(flatten o$5)(init)[$(abs n+2)'\b'++if(n<0)(rjustify(abs n+2))reverse[c,'8': $i'-']\\i<-[0..abs n],c<-[if(n<0)'>''<','=']]]
?t#(Clock n)=accUnsafe clock
|n>t*250=id= ?t
$ =repeatn
Note that this doesn't work on TIO, the link is just for presentation purposes.
Your results may vary if you have a CLOCK_PER_TICK constant other than 1000, the default for x86 Windows Clean.
