in the name of zero

December 9, 2005

paolo’s puzzle (of death)

Filed under: hermetic studies

i solved it! i solved it! on the third day too! gosh, i feel like jesus!

you know you’re screwed when you need to use three or more indentations in your program. in my case, it’s 7 fucking nested for loops.

i _would_ post the code i concocted in all of it’s unadulterated monstrosity but, let the following command spare you from wasting your time.

amerei@heaven ~/git/null $ wc -l puzzle.c
101 puzzle.c

compilation is a bit ricer-ish. and i also had my fingers crossed.

amerei@heaven ~/git/null $ gcc -funroll-all-loops -fomit-frame-pointer \
-march=pentium3 -o puzzle puzzle.c

and finally, i took the plunge.

amerei@heaven ~/git/null $ time ./puzzle
  17
*  4
 ----
  68
+ 25
 ----
  93
	
it took 2745 loops.
	
real    0m0.003s
user    0m0.000s
sys     0m0.002s

there you go. all digits from 1 to 9 arranged in the magic order. no repetitions. thanks man! i learned a lot from this activity. the three days i spent trying to finish the code was never boring! i remember waking up at around 3 am to code because my brain refuses stop working on it. i was also weary that if i won’t codify the idea that woke me up in the first place, i’d forget it soon and i’ll lose my rhythm again.

“make your code work first before putting emphasis on optimizations”

Comments »

The URI to TrackBack this entry is: http://gnurbs.blogsome.com/2005/12/09/paolos-puzzle-of-death/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>


Get free blog up and running in minutes with Blogsome | Theme designs available here