Ad
  • Custom User Avatar

    yep exactly the same issue for me. i even checked with chat gpt to make sure i wasnt going crazy and missing something.

    edit:
    i realize now that there is a solution to get that test case. im surprised that chat gpt didn't get it.

  • Custom User Avatar

    OMG... the amount of time it took me to figure out WHY my code couldn't pass the one test... and then the extra time to figure out which rounding method to use... uugh

  • Custom User Avatar

    OK. Second thouths: you're right. If I dont cut after decimal my condition is met earlier...
    Could it be done without iteration or recurdion....?

  • Custom User Avatar

    If your calculated population is higher than it should be, then you'll reach the target one in fewer years.

    There is: assert_equals(nb_year(1000, 2, 50, 1214), 4), should be: assert_equals(nb_year(1000, 2, 50, 1214), 3)

    And that's what you wrote. The test is fine.

  • Custom User Avatar

    This would explain if I get greater number but I'm getting less than in test!

  • Custom User Avatar

    Read the description again:

    At the end of the 2nd year there will be: 
    1070 + 1070 * 0.02 + 50 => 1141 inhabitants (** number of inhabitants is an integer **)
    

    You need to do that on each year if inhabitants is a float number.

  • Custom User Avatar

    When I realized that I passed over 200 tests, only to fail the last one, my jaw hit the floor

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    You are right. I just made some random changes to see how this "kumite" works...
    But I'm still not sure...

  • Custom User Avatar

    How is a lambda function an improvement? I checked it myself - perfomance of def and lambda is almost identical. Also, one-liners do not improve readability in most cases. You made it shorter, removed choice of not preopening file. Preopening file is good for high perfomance, but it takes lots of RAM, so, sometimes it's better to keep the file closed until the moment you actually need it.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution