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 is interesting but only works if you declare years using the var keyword in the loop definiton, which is not desirable these days. The value of years can be accessed outside of the loop because of the "var". If you use "let" which is the best practice AFAIK, years is undefined outside of the loop.
underated explanation.
really clever approach to such a tricky of logarithmic problem
Can this be implemented using a recursive function?
um... it just doesn't feel right. makes me feel anxious. all you need is an extra line and we can all be happy.
May I ask why? I'm guessing you'd rather store p0 in a new variable and work with that instead but I'm curious as to your reasoning if the function is only small like this one.
This was the kind of idea I was trying to come up with, but I didn't know you could structure a for loop this way. Great solution! I learned a new way to structure for loops. Thank you for the solution!
mutating the argument is not a good idea though.
Very clever. This is a new pattern to me.
I struggled with this as well, but I think I have a decent answer.
In some cases, p0 * percent will yield something like
1200.2
. In reality, we can never have .2 (20%) of a person, so we round down.But importantly, this also holds true for cases where we have 95% of a person. A person is always a whole unit, and therefore a partial person (even 99.99% of a person) cannot exist.
Basically, because a partial of a person can't exist it is equivalent to 0 people, and therefore we always round down when we encounter this type of number.
Idk how much this explanation will make sense to anyone else, but it sorta clicks for me.
Because if you don't use it, you won't get the good result... (???)
Great solution! Can someone explain to me why Math.floor is necessary for this to work?
This comment is hidden because it contains spoiler information about the solution
Thank you - I learned something new!
This comment is hidden because it contains spoiler information about the solution
Loading more items...