Eric Mellen wrote:Ah ok that seems more clear, guess I'll try that.
There is a fabulous book out there called "How to Solve It" by George PĆ³lya. He was talking specifically about math problems, but the lessons can be applied to anything. I highly recommend it to everyone. He give several steps and strategies, including
1) Draw a picture
2) Solve a simpler problem first.
3) Consider special cases
4) Look for a
pattern
there are more, but these are the ones I remember off the top of my head. All of these apply to many CS problems. You'll notice that this is more or less what you did.
Just some advice for the next time...
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors