Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Friday, September 17, 2010

The Parable of the Two Programmers

While I was in San Francisco I found an apparently simple number puzzle on the comics page of the local paper called Challenger. I spent a few minutes trying to figure it out, but when the answer didn't jump out at me it began to look like work and I bagged it. Still it was intriguing, and since it involved numbers and simple rules of arithmetic, I should be able to write a simple program to solve it when I got home, which I did. The program is simple, but it is not elegant. It uses the brute force technique of simply trying one possible solution after another until it happens upon one that works. It took me about a half hour to write it, and five hours to run to completion. Seems there was a bug in my code. I fixed the bug and sent it off again, and five hours later it had again run through all the possible answers without finding a solution. Found and fixed the (apparently) last remaining bug. This time it found a solution in just under 20 minutes. So it works. It is not elegant, or quick. A different problem could take hours to solve.

Now I want to store it someplace on the web, mostly for practice. This particular piece of code is not particularly useful, but I might have other stuff I want to post, and someplace that programmers visit might be good. I came across a site one time that purported to store snippets of code, and that kind of seemed like a good thing as well. I was sure I bookmarked it, but now I cannot find it, so I go Googling and I find a bunch. Looking around I find one site with a blurb promoting

The Parable of the Two Programmers

which is a very fine story of life in the programming lane.

I tried Dream-In-Code, but after I posted my program, I couldn't find it. Not only that, their list of snippets does not appear to be in any logical order, nor is there a sorting ability. They have a search capability, but it didn't help. Worst of all though, is it is slow. I have no more time to spend on this right now, so I posted the program as a Google document. Not the best solution, but it will have to do for now.


No comments: