The Python Challenge is another one that I found ( www.pythonchallenge.com ) but I don't like it as much since it's one of those ridiculous puzzle sites instead of straight-up programming challenges.
Some of those look cool. Others, like the first problem, I can't conceive of an elegant solution that requires a program. Just a solution that requires an algebraic expression of about 10 terms.
"Some of those look cool. Others, like the first problem, I can't conceive of an elegant solution that requires a program. Just a solution that requires an algebraic expression of about 10 terms."
If you're talking about problem 1, I did it with a one-liner in Haskell wit some list trickery. It's not particularly efficient but it got the job done in under a second.
Discussion (9)
Thank you James. I hadn't heard of this site before.
The Python Challenge is another one that I found ( www.pythonchallenge.com ) but I don't like it as much since it's one of those ridiculous puzzle sites instead of straight-up programming challenges.
Some of those look cool. Others, like the first problem, I can't conceive of an elegant solution that requires a program. Just a solution that requires an algebraic expression of about 10 terms.
Just trying things like this will help the learning process.
"Some of those look cool. Others, like the first problem, I can't conceive of an elegant solution that requires a program. Just a solution that requires an algebraic expression of about 10 terms."
If you're talking about problem 1, I did it with a one-liner in Haskell wit some list trickery. It's not particularly efficient but it got the job done in under a second.
(I meant to type 'wit' instead of 'with'. My native accent is returning to da point dat I type in it, I guess.)
(It is, if I did my math right, the sum of 3 finite sequences. I think I did it faster on paper than I could write it on a computer.)
Well, yes.
But it is also: sum(1..199)*5 + sum(1..333)*3 - sum (1..66)*15
and the summations of sequences can be done in 4 terms.
(L[1] + L[n)) * n / 2