Wednesday, October 17, 2007

School days

Many moons ago, when I was still flirting with GW Basic et al in school, we had a computer teacher; who would always come up with what we used to call "crazy" problems. I don't think most of her students had enough brain powers then; to write those programs (and I doubt, most of them; including myself; have the requisite brain powers even now)! One problem which always has bugged me is this:
Given a positive integer, find the series of lower integers which add up to it. Here's an example:
assume the given positive integer is 5, so the series of lower integers will be:
  • 1+1+1+1+1
  • 1+1+1+2
  • 1+1+3
  • 4+1
  • 2+2+1
  • 3+2
  • 1+4
IIRC, none of her students were able to solve this problem, and I don't think it was even possible in GW Basic, cause most of the series problems generally require recursion (maybe, you can implement recursion in Basic using labels and Go To). Now, that I do know quite a few languages which allow recursions and have more brain powers, I still haven't been able to solve this problem (granted; I never really spent too much time on it). Anyway, I'll take the lazy way out and see if anyone reading this is interested enough in taking this as his/her weekend project.

No comments:

Post a Comment