&!)')$0<.0.>.;/-{@_
Try it online! or on hexagony.net
In hexagon layout:
& ! )
' ) $ 0
< . 0 . >
. ; / -
{ @ _
Completely ungolfed:
& ! ) {
. . . . .
. . . . . .
& ) 0 ; 0 ' -
. . . . . .
. . . . .
@ . . .
The solution works by maintaining an invariant at the beginning of each iteration that the current memory cell zero or negative (current number - 100
on all iterations except the first one) and the cell to the left is the current number.
&!
copies current number from the cell to the left (due to the memory invarant) and prints it
)
increments current cell, so it will be current number for the next iteration
{
moves to the memory cell to the left, pointing towards two cells with zeros
&
copies zero from one of those cells into current cell
)0;
sets current cell value to 10 (ascii code for newline) and prints it
0
sets current cell value to 100 = 10 * 10 + 0
'
moves to the memory cell to the back right without turning memory pointer around, so now it points towards next number to the left and 100 to the right.
-
computes next number - 100
Finally pointer leaves the right corner while moving to the right, so it wraps around to the top row if next number - 100
is zero or negative, or to the bottom row otherwise where it terminates at @
.
Golfed solution fits everything into a hexagon with side 3 by taking advantage of changing instruction pointer's direction, grid wrapping and idempotency of -
operator.
I don't know if a solution with side 2 (7 cells) is possible, but this solutions uses 9 different operators without counting the ones that control direction, so it definitely won't fit. A more optimal side 3 solution might also be possible.
0
. Which is what makes this challenge interesting, IMO. \$\endgroup\$