We set our limits
A little over three years ago I graduated from college and applied for a job as a Programmer. I passed the initial test which is on paper and then proceeded on a two day internship which involved practical programming among other stuffs.
I was able to solve most of the problem except the last one. It just seem too difficult for me at that time (and I believed in this for quite some time) as if I had to slay a wild flying dragon just with a knife. Fortunately I still got the job, but I never looked back at that dragon like a scared little baby believing that it would devour me alive or toast me with it's breathe of fire.
Yesterday, I remembered that Dragon and thought that keeping it somehow affects my confidence with my skill as a developer. Finally I decided to get my hands dirty and stifle the beast from the past in order to get rid of that limit that I set upon myself. AND FINALLY I DID IT.
The challenge is to display a number spiral based on a number n. For example the input is 3. We need to have the following as a result:
9 8 7
2 1 6
3 4 5
3 X 3 is 9 and starting from the upper left we put 9 moving clockwise and priting then next lower number every step until we write the number 1 in the screen.
Here is my solution:
{% gist lyc4n/d5b6b23d3d129a35fe8939170bef17d2 spiral.rb %}
Yes we can!
Tags: