Thursday, January 6, 2011

When is it OK to "cheat"?

As I mentioned, one of my New Year's resolutions is to try and get 1 Project Euler problem done per week. I should openly admit at this point that I have been painfully slow in solving even the easiest of the problems, and recently I've been stuck on Problem #3, which requires you to find the largest prime factor of a big number. I've been struggling to figure out the best way to approach it, and right now I have a program that literally loops through a list of prime numbers and prints them. Pathetic.

So, in the interest of getting a different perspective, I Googled the problem. I felt uncomfortable doing this. I feel like I should be able to complete these problems with no help, if I just sit and think about it long enough, but obviously this was getting me nowhere. I found a solution that I'm going to implement that makes far more sense, is cleaner, and isn't pathetically brute-force like my current code.

So, the question that lingers in my mind is, how important was it that I worked it out myself vs. looked up a blogged solution vs. just looked up sample code? At what point am I really just cheating myself in the interest of not having to think too much? Is it even that important in this case?

I'm working on Project Euler to improve my shoddy math skills, as well as attempting to keep up with fairly basic programming (usually to learn how to use new languages as well, such as Lisp), so I suppose as long as I still accomplish those goals, it's all good.

No comments: