Instead of functorial lifting into the list (resulting in O( n^{2} )) I use the loop function iterateUntilM to iterate the slightly modified printElement function until the spiral is printed: O(1)

In the printElement function, elements are indexed by a counter from 0 to n^{2} - 1, their position in the spiral can be derived from the index by division modulo n: (row,col) = quotRem counter n.

## re: Challenge - Print Spiral VIEW POST

TOP OF THREAD FULL DISCUSSIONInstead of functorial lifting into the list (resulting in O( n

^{2})) I use the loop function iterateUntilM to iterate the slightly modified printElement function until the spiral is printed: O(1)In the printElement function, elements are indexed by a counter from 0 to n

^{2}- 1, their position in the spiral can be derived from the index by division modulo n: (row,col) = quotRem counter n.