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 !!

UPDATE : An Alternate solution was developed and posted online in less than an hour (on StackOverflow) by AETH (profile).

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.

Advertisements

~ by CVS268 on Sat, 20 Mar, 2010.

One Response to “The Mystery Spiral : PART2”

  1. i cracked dis one too 😉 4 code click http://www.bloggleminds.co.cc

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s