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

    Most solutions are either iterative or recursive. There is one exception, but I don't like how it solved that edge case, hardcoding it.

  • 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

    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.