"
*
*
*
*@
*}
*|
*/
*
*.
*/
Try it online!
Aha! It turns out just printing ten asterisks ten times does beat out my more complex answer. Unfortunately though, writing this program exposed not one, but two bugs in my interpreter. Below is my longer, but higher effort solution:
_9'2
^*|
\ !]
(.n
n?\
\%!|
n)+\
Try it online!
One of my more compact Cascade programs. I'm still not sure if it would be shorter to just print 10 asterisks 10 times instead of using a counter, but I'm satisfied with this, especially how the bottom intersects with the top.
Explanation
The easiest way to understand the code is know the basic structure. Each instruction can take up to three inputs, each one below it.
+
lcr
These are the left, center and right arguments. In this case, the +
instruction is dyadic, meaning it takes the left and right arguments. Most instructions are either dyadic or monadic (taking one argument, the center one). The /\|
instructions take only the argument they are pointing to, and the !
instructions skips over the center and takes the argument two below it. Each of these arguments can themselves be code instructions, meaning they chain together in a prefix like notation. For example, this code could be represented by the recursive Lisp-like code:
code = (if (0==(n=dec n))
doboth
(print (
if (% n (+9 2)) ('*')
else (inc 9)
))
(code)
)
If that doesn't make sense, here's an expanded look at the code, which is still a little confusing, but it at least has an idea of which parts are connected to each other through the |/\X
s. Note that the top and bottom rows are the overlap between the two (and same with the left and right).
\ |/|\ \
_ 9 ' 2
/ \ | /
^ * |
/ \ |
\ ! ]
\ \ \/ \
( . n/
| | |
n ? \
/|\ \
\ % ! |
X \\ |
n ) +/\
\ |/|\ \
Starting from the top left corner, we have the first check (_
) which executes the right branch only if the left is successful. The left goes down to the ]
, which sets the n
variable (initially 110) to the decrement ((
) of n
, i.e. n=n-1
. The check then takes the result of this (the new value of n
) and continues if it is positive. This moves onto the branch instruction on the right (^
), which executes both the left and right branches.
The left prints (.
) the value given by the choice instruction (?
). This branches depending on the center value, which is the modulo (%
) of n
and the addition (+
) of 9
and 2
. Note that this wraps around to the top again for those digits. If n%(9+2)
is 0, then we branch left, which navigates around the %
and returns the increment ()
) of 9
, printing a newline. If it is not divisible by 11
, then we go right, skip over the +
with a !
, and return the character ('
) of *
to print.
Now the right branch of the ^
skips over the n
, then goes right, down, and right again, wrapping around both the right edge and the bottom edge to loop back to the _
in the top left. This now loops over the exact same code until n
has reached 0
, printing ten asterisks and then a newline.