Hexagony, 37 35 34 31
10"+}(=${";<$<1}42/.0@_=<>\;>(_
Expanded:
1 0 " +
} ( = $ {
" ; < $ < 1
} 4 2 / . 0 @
_ = < > \ ;
> ( _ . .
. . . .
Try it online
Basically just has two for loops counting down from ten to zero, printing out an asterisk on the inner loop, and a newline on the outer loop.
Explanation:
This program consists of three main parts: initialisation of memory, a loop which prints ten asterisks and a loop which prints a newline. The loop which prints a newline also contains the loop which prints the asterisks.
First, the code runs the totally linear memory initialisation. The code works out to be: 10"+}42
. This sets the memory of the nearby edges to look like:
10 \ / 10
|
42
42 is the ASCII code for the asterisk character, and the two tens will be used as our loop counters. Of note is that the memory pointer is currently pointing away from the two tens, so moving backwards will put us on one of the tens.
Next, we start the astersisk printing loop. Linearly, the code looks like: ;".._(
. This prints out an asterisk, moves the memory pointer backwards and to the left and finally decrements the value there. After one iteration, the memory would look like:
10 \ / 9
|
42
Then we hit the loop condition: the bottom-leftmost >
. If the edge we just decremented is still positive we bounce around and execute a {
to move us back onto the 42. Then we hit a $
and return to the beginning of the printing loop, the ;
, by skipping the <
. If the value was zero, we head into the other loop.
The outer loop begins by resetting the recently zeroed memory edge to ten (this is the 10
in the code, going southwest). Then, we print out this ten as an ASCII character, which is a newline. Next, we move onto the other memory edge and decrement it with {(
and then execute what amounts to a bunch of noops: =${_=
. Now, after one iteration of this loop, memory would look like:
9 \ / 10
|
42
This time, the memory is facing outwards from the edge storing a nine in the above diagram. Next we execute the <
which acts as the loop condition for the outer loop. If the value was non-zero we bounce around off of some mirrors, then begin executing meaningful instructions again after entering the top of the hexagon at the "
moving southwest. This causes us to move backwards and to the left, onto the 42 again, but facing inwards. Then the =
flips our direction, resetting the state properly to begin the inner loop again. If the edge was set to zero, the instruction pointer goes on a little adventure which does nothing until it exits the program.
The adventure begins by the instruction pointer venturing northeast, perilously disregarding the safety of the cardinal directions. It bravely ignores a mirror that is aligned with its diretion (/
) and heroically leaps off of a trampoline ($
) entirely evading the deadly trap of another, totally identical trampoline. Staring out at the emptiness of uninitialised hexagon edges, the pointer, without faltering for a moment, adds the two blank edges it faces together, setting the current edge to their sum: 0 (the edge was actually zero beforehand, but the pointer likes to believe this was pretty important). Since the edge is zero, the pointer makes a left turn at the fork in the road, walking into a mysterious forest (of hexagons). There, it finds itself disoriented, moving forwards and backwards and forwards, until it winds up at the same place in memory as it started. Thinking that the problem must be that the current edge was set to zero last time, the pointer bravely plants a 1
into the current edge. Then, the noble pointer investigates another path, one laid with... a trap! The current edge is decremented and set back to zero! The pointer, dazed by the shocking turn of events, stumbles back into the trap setting the current edge to negative one. Infuriated, the pointer attempts to return to the comparatively pleasant forest, only to notice that since the current edge is not positive, the paths have yet again shifted and the pointer finds itself walking into a cave. And by a cave, I mean the mouth of a giant hexagonal worm. Helpless, the pointer curses the sexinity with its dying breath. Also, the program ends.