# Create your own Gym Exercise and follow along irl

Let's do an exercise together, shall we? Simply follow the movements of the stickman. What stickman you ask? The one we are about to create!

Make a program that allows for a string-input only containing integers, and outputs the following nine stick-figures with an interval in between:

 @  \@/ |@_ _@| @/   \@ |@| \@\ /@/
/|\  |   |   |   |   |   |   |   |
/ \ / \ / \ / \ /|\ /|\ / \ / \ / \
1   2   3   4   5   6   7   8   9


This will result in an animation, which we can then follow along irl.

Here is an example of the output created when the input is "123245762":

Some rules:

• This is tagged , so shortest code in bytes wins
• The input is a string only containing [1-9] with a length potentially varying from 2 to 100 characters **
• The animation must be an endless loop
• The interval time must be 750 ms
• No duplicated adjacent integers are allowed in the input - this also includes the first and last integers of the input (see the seventh and eight test cases) **

** How it fails in case of invalid input is completely up to you, but it should be clear that it fails. It could throw an exception; simply return at the start; reboot your PC; delete it's own source-/compile-code; hack into the military and shoots a rocket to the compiling GPS-location. Your call. EDIT: It's not allowed to simply display a (correct / half) animation as failing input. It must be clear that something is wrong with the input for the failing testcases below. Thanks to @user81655 for bringing this to my attention, hence the edit.

Subrules:

• Please post the gif for one of the (non-failing) test cases below in your answer, which you can make very easy with the following program: screentogif.codeplex.com (Any other gif-creating program is also allowed of course.)
• Bonus points if you actually do the exercise alongside the animation irl when it's finished. ;)

Correct testcases:

1. 123245762
2. 65
3. 121234346565879879132418791576

Failing testcases:

1. 2 // Too few characters
2. 7282918274959292747383785189478174826894958127476192947512897571298593912374857471978269591928974518735891891723878 // Too much characters
3. 1232405762 // Containing invalid input (the 0)
4. 112212 // Fails because of the 11 and 22 present
5. 1232457621 // Fails because of the starting and leading 1
• IMO this is a borderline dupe of this – Peter Taylor Apr 6 '16 at 11:44
• BTW, making edits after a challenge is posted is discouraged. – Blue Apr 6 '16 at 19:17
• imo the input validation ruins the challenge. – FlipTack Feb 12 '17 at 19:36
• @FlipTack You're indeed right. I should have just kept with the challenge and assume all input is valid. This was my very first question here on PPCG. Bit too late to change it now, though. – Kevin Cruijssen Feb 13 '17 at 7:44

## Pyth, 114 bytes

.V0j@cv.Z"xÚí» À0DW¹NM@+Üñ\">íÂA¸êÄÓw»3±2þ&'NövfAé8é~0,p'ÆìÞúr_'¥,d!YÈBíéqs"3tv@zb.d.75


Try it here

(No pausing, non-infinite)

• Hmm, it isn't possible to return/throw or loop infinitely in Pyth? Or it will take too much bytes/is too time-consuming to make? (Currently it works the same for all correct testcases, as well as all failing testcases. And it also adds in the output for 0.) Regardless, thanks for the entry. Definitely one of the most unreadable code-snippets for this entry is my guess. :) – Kevin Cruijssen Apr 6 '16 at 11:02
• The online interpreter doesn't flush IO during a sleep so it isn't noticed. You did say you wanted an infinite loop so I'm not sure what you're asking there. "How it fails is up to you" - I'm doing undefined behavior for this; the code might do anything (even though it SHOULD behave the same) Also I'm expecting this to be relatively readable compared to some possible entries – Blue Apr 6 '16 at 11:06

# SpecBAS - 387 bytes

1 DIM m$=" @"#13"/|\"#13"/ \","\@/"#13" |"#13"/ \","|@_"#13" |"#13"/ \","_@|"#13" |"#13"/ \","@/"#13" |"#13"/|\"," \@"#13" |"#13"/|\","|@|"#13" |"#13"/ \","\@\"#13" |"#13"/ \","/@/"#13" |"#13"/ \" 2 INPUT a$: o=0
3 IF LEN a$<2 OR LEN a$>100 THEN 10
4 FOR i=1 TO LEN a$5 n=VAL(a$(i))
6 IF n=0 OR n=o THEN 10
7 CLS : ?m\$(n): o=n: WAIT 750
8 NEXT i
9 GO TO 4
10 CLS : ?" @"#13"-O-"#13"/ \"#13"FAT"


Keeps looping until you press ESC. Failure to exercise properly (incorrect input - in this example a 0 as one of the steps) leads to fatness. The GIF loops, in the program it just stops at that point.

#13 is the SpecBAS equivalent to \n and lets you include line feed in strings.

• "FAT" :D ...... – Adam Varhegyi Feb 16 '18 at 14:27

## JavaScript (ES6), 165 bytes

f=s=>{n=s[0];e.textContent=' @ \\@/|@__@|@/  \\@|@|\\@\\/@/'.substr(n*3-3,3)+(n>1?
|
:
/|\\
)+(n<5|n>6?'/ \\':'/|\\');s=s.slice(1)+n;s[0]-n&&setTimeout(f,750,s)}
f("123245762")
<pre id=e>

# JavaScript (ES6), 210 bytes

s=>setInterval(_=>(c=console).clear(i=0)&c.log(, @
/|\\
/ \\,\\@/
|
/ \\,|@_
|
/ \\,_@|
|
/ \\,@/
|
/|\\, \\@
|
/|\\,|@|
|
/ \\,\\@\\
|
/ \\,/@/
|
/ \\.split,[s[i++%s.length]]),750)

• How does this handle the rules about excluding 0 and duplicates? – Morgan Thrapp Apr 6 '16 at 13:48
• @Morgan'Venti'Thrappuccino I was under the impression that invalid inputs don't need defined behaviour, since it says How it fails in case of invalid input is completely up to you. I just handle invalid input by displaying an animation. :P None of the other existing answers checked this either, however the answer the OP just posted does, so maybe he did want us to handle invalid input. – user81655 Apr 6 '16 at 14:01
• "I just handle invalid input by displaying an animation. :P" Lol.. That's one way of looking at it. xD I'll edit the question. – Kevin Cruijssen Apr 6 '16 at 14:43

# Mathematica, 252 bytes

i=0;Dynamic[Uncompress["1:eJxTTMoPSuNkYGAoZgESPpnFJcFCQIaCQ4yBoZF+TUwMmFaIiQELx8Q46IMEFGrgwoJA4RqHeCyi8Q41aKICQFEUA2qg5gIlHdCEIeaimyAMcQTEWWj26aO7DQDaqDEh"][[FromDigits[#~StringTake~{i=i~Mod~StringLength@#+1}]]],UpdateInterval->3/4,TrackedSymbols->{}]&


Would be nice if someone could create a GIF. Run in a notebook.

# Python3, 338 bytes

import os,time
p=" @ \n/|\\\n/ \\","\\@/\n | \n/ \\","|@_\n | \n/ \\","_@|\n | \n/ \\","@/ \n | \n/|\\"," \\@\n | \n/|\\","|@|\n | \n/ \\","\\@\\\n | \n/ \\","/@/\n | \n/ \\"
i=input()
for j in range(len(i)):(i[j]in"123456789"and i[j]!=i[(j+1)%len(i)])or exit()
while 1:[[time.sleep(0.75),os.system("clear"),print(p[int(j)-1])]for j in i]


# Java 8, 663636634631596355 354 bytes

Just for the lols I tried to make the program in Java. Admittedly I'm pretty bad at golfing and regexes, so it can most likely be golfed (a lot?) more. Nevertheless, here it is in Java 7.
Now almost two years later and I almost halved the code in Java 8. Why did I ever made those rules about validating the input and requiring a full program, though... >.> I hate my past self now..

interface M{static void main(String[]a)throws Exception{if(!a[0].matches("[1-9]{2,100}")|a[0].matches("(.).*\\1|.*(.)\\2.*"))return;for(;;)for(int c:a[0].getBytes()){c-=48;System.out.printf("%s%n%s%n%s%n",c<2?" @ ":c<3?"\\@/":c<4?"|@_":c<5?"_@|":c<6?"@/ ":c<7?" \\@":c<8?"|@|":c<9?"\\@\\":"/@/",c<2?"/|\\":" | ",c%7>4?"/|\\":"/ \\");Thread.sleep(750);}}}


Explanation:

Try it online. (After it has timed out after 60 sec.)

interface M{                     // Class
static void main(String[]a)    //  Mandatory main-method
throws Exception{          //    Required throws for the Thread.sleep
if(!a[0].matches("[1-9]{2,100}")
//   Validate 2-100 integers only containing 1-9
|a[0].matches("(.).*\\1|.*(.)\\2.*")
//   Validate no adjacent duplicated char (with wrap-around)
return;                    //    If either isn't valid, stop the program
for(;;)                      //   Loop indefinitely
for(int c:a[0].getBytes()){//    Inner loop over the characters of the input
c-=48;                   //     Convert character-code to integer
System.out.printf("%s%n%s%n%s%n",
//     Print:
c<2?" @ ":c<3?"\\@/":c<4?"|@_":c<5?"_@|":c<6?"@/ ":c<7?" \\@":c<8?"|@|":c<9?"\\@\\":"/@/",
//      The top part of the stick figure
c<2?"/|\\":" | "       //      The middle part of the stick figure
c%7>4?"/|\\":"/ \\");  //      The bottom part of the stick figure
Thread.sleep(750);}}}    //     Sleep 750 ms


Gif:
(Note: Old gif, since it's clearly jdk1.8+ now.)

• Usually we say Java 7 to refer to this version of Java as 1.7 can confuse some to think that it is Java 1 revision 7 – GamrCorps Apr 6 '16 at 15:11
• The long if statement could be turned into something like p(new String[]{" @ ",y,"|@_", ... }[c-49]);if(c==49){p(x);l();}else if(c==53){w();p(x);}else d();. Also I think that defining l and w wastes characters, now that they're only used twice. Consider letting s instead be char[] s=a[0].toCharArray()`; all the other operations with it are much shorter, then. – Alex Meiburg Aug 1 '16 at 17:13