This is a 7kyu question in codewar but it's a bit tricky.
I remember I solved it after tens of submissions, because one or two tests were failed for some reason.
Turned out that I should have to deal with integers more carefully.
Here is an answer for ruby version:
def nb_year(p0, percent, aug, p) year = 0 while p0 < p year += 1 p0 = spawn(p0, percent, aug) end year end def spawn(p, percent, aug) (p + (p * percent / 100).floor + aug) end
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is a 7kyu question in codewar but it's a bit tricky.
I remember I solved it after tens of submissions, because one or two tests were failed for some reason.
Turned out that I should have to deal with integers more carefully.
Here is an answer for ruby version: