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.
You could make this a little more difficult by also accepting negative amounts (formatted correctly ;) and requiring the function to throw an error if the running total drops below zero.. it's fine for beginners though.
Yeah implementing the correct rounding is significantly harder than the actual task.
That does change difficulty level across languages.
I mainly meant efficient in the code golf sense of not requiring many characters. :) Yes, the floor division method is more performant.
This comment is hidden because it contains spoiler information about the solution
Omg. Of course. I'm an idiot. XD
Good thought, explicit tests.
Language default rounding may be different between languages, but that's translators' problems. :]
Thanks for the feedback! I updated the description to clarify that respondents should use "rounding to even", which is (to my understanding) the default behavior of both
round
andformat
in Python. I suppose I should add explicit tests for this too.Rounding method is unspecified. For sh!ts and giggles, read Wikipedia how many ways to round a number there are.
Several of these would be applicable to this kata ( at least round half up, round half away from zero, and round half to even ).
Rounding is never simple ..
A little inefficient because it checks pairs twice, but simple and intuitive!
This comment is hidden because it contains spoiler information about the solution
huh. I tried this and hit a timeout.
Hey, that walrus operator line is pretty neat.
Agreed on the rounding constraint. The partial persons in the intermediate results are essentially just modeling variance in the year-to-year growth rate. (E.g., 1/3 of a person per year just means every third year you get an extra person.) If they're gonna make us round, it should be at the end, not in every step.
This is a really neat solution!
Loading more items...