Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Jump overflow and underflow semantics should definitely be specified in the problem, omitting them and then let people try to guess does not make a good problem, but a bad spec.
(For those stuck: Overflow should make your program terminate, not throw exception. Underflow is not relevant (I think), but I made it just stop at the first instruction.)
Thank you very much!
One-liners tend to have that side-effect... And it probably is the case here.
However, remember that «Premature optimization is the root of all evil»: If I would have to create a big bunch of variables to avoid recalculations, the code would become unreadable quite quick.
Furthermore, nothing is won when you replace two calculations with an assignment and a calculation! You only start to win something with three or more recalculations avoided!
Sorry!
And I would never write this in production code!
A simple refactoring into a helper function would make this much more digestible!
Alas, the "one-liner factor" was too appealing... :)
I don't know if this has been updated, but I have been able to solve this problem. Perhaps you are summing number by number? There are more efficient ways!
Best comment ever!