Ad
  • Custom User Avatar

    Impressive progress! This solution is about 10 times faster than the first. And this is one of the fastest solutions for today.

  • Custom User Avatar
  • Default User Avatar

    C (also the case for the previous 32-bit signed comment)

  • Custom User Avatar

    Which language?

  • Default User Avatar

    Perhaps 'n' should be revealed on a failure in the random tests?

  • Default User Avatar

    When you get a random test wrong, the test framework apparently reports a truncated 32-bit signed result (my guess) instead of the expected 64-bit unsigned result for the failed test.

  • Custom User Avatar

    Fixed, Thanks.

  • Default User Avatar

    Range: 0 to 100000000

    There's a fixed test with n = 101101291, and the random tests seem to take it even further.

  • Custom User Avatar

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

  • Default User Avatar

    You can do the change of percentage when you want... but calculate with the correct one at the end of the month. Once more, description says:

    Calculations are processed at the end of each considered month

    My solution is not maybe the best but if you have time take a look at it:-)

  • Default User Avatar

    That gets rid of the ambiguity, thanks! However, I must say that changing the percentage at the end of the month and then calculating with it for that month is borderline criminal. But perhaps expected when bankers and car salsemen are involved.

    The honest thing to do is to change the percentage at the start of the month and calculate with it at the end of the month. But maybe that's just me...

  • Default User Avatar

    Description:

    percent of loss increases by 0.5 percent at the end of every two months

    • So to make your calculations at the end of month 1 you use the initial loss
    • .............................at the end of month 2 you use the initial loss increased by 0.5 percent

    With the example given in the description
    nbMonths(2000, 8000, 1000, 1.5) should return [6, 766]
    you get for "months", "percentLossByMonth", "available" (rounded):

    1   1.5   -4910
    2   2.0   -3792
    3   2.0   -2676
    4   2.5   -1534
    5   2.5   -396
    6   3.0   766
    

    The thing to understand is: at each step you use the correct percentLossByMonth before doing your calculations. Is that clearer?

  • Default User Avatar

    It is impossible to know if the bi-monthly loss increase should first be applied at the end of the first or second month. It is thus impossible to get the kata right without luck or trial and error.

    Please fix the description.