Ad
  • Custom User Avatar

    g964: The example is correct (and very useful); the description's wording is certainly inaccurate, however.

    To be fair, I think a lot of people learnt a few things from solving this kata: Always be very careful when reading (or writing) your problem description; use tests and logging to make sure the behaviour of your code matches with the expected reality!

  • Custom User Avatar

    Depreciation is not something that suddenly occurs at a single moment. It is a process that takes place over a period of time.
    If depreciation rate increases in the end of a month (say Feb 28 23:59), that normally means it will only start excercising its depreciating effect from March 01, 0:00 on.
    So, according to description, if rate changes end of second month, then first 2 months must be discounted/depreciated at a rate of 1.5.
    A theoretical case can be made that the amortisation rate is not from regular wear, but from somebody with a crowbar smashing the car in very regular intervals just before end of month. But no talk of such thing in the description.
    jimmy.clayton is correct in their 1. remark.

  • Default User Avatar

    The example has the rate increasing from 1.5% to 2% at then end of the 1st month, not the second as described.

    wrong:

    end month 1: percentLoss 1.5 available -4910.0
    end month 2: percentLoss 2.0 available -3791.7999...
    

    The dollar amount left over needed to be rounded to the nearest dollar. This was never mentioned

    wrong:

    766 is the nearest integer to 766.158... (rounding 766.158 gives 766).