The Mystery Spiral : PART2
Finally, I did manage to upload the code.
Squeezed it into a “lean-mean” 99 liner. 😉
I also have a debug-version that logs the progress as the code executes.
Mail me @ 2.6kilohertz@Gmail.com for the debug version of The Mystery Spiral.
UPDATE : There is a fundamental flaw in the program that might cause it to crash in certain circumstances. Unfortunately, I discovered the flaw only after i uploaded the code. (special Thanks to Péter Török ;-)) Rather than correct the code, I am leaving it as an exercise for the reader to identify it. Good Luck !!
The ALT soln. does NOT require N*N memory. Rather it prints each line using a pre-calculated formula.
Checkout the ALT Soln. HERE
Finished The Mystery Spiral?? Here’s a slightly more interesting problem…
THE MYSTERY SPIRAL: PART 2
Try improving upon the program so that it not only generates the numbers in spiral order;
But also prints the numbers in a spiral. i.e. if we were to slow the program to a crawl (single-step thru the code) then the numbers printing should resemble the spiral slowly circling around to the centre.