You may have seen Jacob's Ladder in children's science museums. If you're not familiar with what they look like, there are several images and video examples on the Wikimedia Commons. The challenge today is to create an animated ASCII version of the electrical gadget. In the end, it should look something like this:
Ladder Construction
Here is the basic shape of a ladder with a height (H) of 6:
6 \ /
5 \ /
4 \ /
3 \ /
2 \ /
1 \ /
0 ¯¯
The numbers on the left simply indicate row number for this example and should not be included in the output. We'll refer to a given row by it's number (R). Row 0 is the bottom ¯¯
. Each row 1 through H is comprised of four parts:
- A space
(U+0020) repeated (H - R) times
- A back slash
\
(U+005C) - A space
(U+0020) repeated (2 * R) times
- A forward slash
/
(U+002F)
Row 0 is identical except both the slashes are replaced with a macron ¯
(U+00AF). Trailing whitespace at the end of each line or below the ladder is OK. Leading whitespace is not.
Arc Construction
Once the ladder is constructed, you can create arcs between the left and right side. One arc is entirely within a row and replaces the spaces between the leading \
and trailing /
. Therefore, row 2 will have 4 characters in its arc, row 3 will have 6, and so forth. Each arc is composed using the following rules:
- The only allowable characters are
_/¯\
(U+005F, U+002F, U+00AF, U+005C) - In order to ensure a smooth appearance, any
¯
or/
must be followed by a¯
or\
- In order to ensure a smooth appearance, any
_
or\
must be followed by a_
or/
- The two rules above apply to the edges of the ladder as well
- The three rules above effectively mean that the first character in the arc must be
_
or/
and the last character must be_
or\
(\¯\_//
is invalid on both ends but\_/¯\/
is OK) - There must be a non-zero chance for each allowable character to occur at a given point
- Each arc is independent from every other arc
Animation
The life of a single arc is created by starting it at row 1 and "moving" it up one row at a time until it reaches the top. I.E., first generate an arc at row 1, then set it back to spaces and generate an arc at row 2, and so forth. Given a number of arcs to show (N), show the complete life of that many arcs one at a time using the following guidelines:
- Only one arc should be "alive" at any one time. The next arc cannot start until the current one reaches the top and then extinguishes.
- Each row of the arc's life should be shown for exactly one frame
- There should one frame of just the basic ladder (with no arcs) before a new arc starts (optional before the first arc)
- The animation should show the full life of N arcs. If N=0, it should animate random arcs forever until stopped.
- If N>0, you may still loop the animation forever but it must be a loop of the same arcs over and over. (The example GIF at the top of this post has H=6 and N=3 but it loops forever.)
- The animation should occur in-place. That is, each frame should completely overwrite the next frame and be in the same location.
- The length of each frame can be whatever you want but make it watchable by a human (I.E., use your common sense: 0.01s/frame and 30s/frame are both unacceptable.)
Input / Output
- Input and Output can be in any standard format
- You can export a GIF, write text to the screen, output a single file for each frame, or any other reasonable means
- Standard loopholes are forbidden
- The height of the ladder H will be a positive integer
- The number of arcs to show N will be a non-negative integer
- Both H and N are taken as inputs in any order you choose (Please include the order in your answer)
Winning Condition
This is code-golf so the shortest code wins.
the first character in the arc must be _ or / and the last character must be _ or \
andThere must be a non-zero chance for each allowable character to occur at a given point
. In order to be symmetrical, both the first and last character would have to be_
every single time which means there is zero chance of either/
or `\` occurring. \$\endgroup\$0xAF
is»
. \$\endgroup\$