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.
This comment is hidden because it contains spoiler information about the solution
[updated wiki link](https://en.wikipedia.org/wiki/Guard_(computer_science)
May anyone elaborate on this solution a bit please? It looks very nice but I've never used attrgetter before.
I do not understand how the Kata description " How many years does the town need to see its population greater or equal to p = 1200 inhabitants?" when we have used population < target.
Feel free to design an advanced spinoff of this puzzle though where this may be important.
Citing the kata description:
aug is an integer, percent a positive or null floating number, p0 and p are positive integers (> 0)
Why catch errors when they are not expected by definition?
What if aug (inhabitants coming or LEAVING each year) is negative and bigger than % increase? It's a really efficient code but cound do with an error catcher, maybe?
because the decision is old enough I think
nice we almost have the same code
seventh base test fail if not converted to int.
p0 += int(p0 * percent / 100 + aug)
nice
Mutability. Mutable objects can be changed. Immutable objects cannot.
p0 is immutable because it is an integer. It is reassigned with each iteration, not mutated.
The test code calls this function with:
Test.assert_equals(nb_year(1500, 5, 100, 5000), 15)
1500 was not harmed during the execution of this function.
If you assigned p0 to the value 1500 and then passed p0 in the calling function, p0 would still point to 1500 upon funtion completion.
If you want a funtion to change your objects, pass a mutable object, like a list.
Generally, if x = [], then x[0] = 1 (mutating) and x = [1] (reassigning) are two different operations. both x-es have the same value, but the mutating version will change x in the calling function, and the assignment has local scope.
Please correct me if I am wrong.
This comment is hidden because it contains spoiler information about the solution
that is known as a
decimal point
;) it basically has the effect of turning an integer into a floatwhat is that dot after 100?
Loading more items...