Ad
  • Custom User Avatar

    The description is unclear how NI is related to the overall calculation, and it's not mentioned what is the input. Is it the monthly pay or the yearly pay?

  • Custom User Avatar

    Consider removing the rounding, and just check the result approximately (e.g., to within 1e-6 absolute or relative error, or whatever the Codewars standard is). This will immediately make incorrect solutions not pass, even if they are not (randomly) tested at difficult inputs near bracket changes. Furthermore, it will eliminate any chance of having to round near k + 0.5, where small differences in floating-point arithmetics can make some solutions round up, others down.

  • Custom User Avatar

    Please make it such that at each tax bracket change, 10x'th pound is taxed at the previous rate and 10x+1'th pound at the next rate. Anything else is confusing and not in line with the description. For example, if the current reference solution is given the input 12572, it will only tax the 12572nd pound, not the 12571st pound.

    A similar problem holds for the insurance cost. From the description it's not clear how the 1048th pound is to be taxed.

  • Custom User Avatar
    £209148
    expected 124941 to deeply equal 124942
    

    It appears my solution is off by one. Let's try to work this out by hand:


    Yearly tax:

    • First 12570: tax = 0
    • 12571 to 50270: tax = 20% * 37700 = 7540
    • 50271 to 150000: tax = 40% * 99730 = 39892
    • over 150000: tax = 45% * 59148 = 26616.60

    total tax = 74048.6, rounded to 74049


    National Insurance:

    Monthly Income = 209148 / 12 = 17429

    • First 1048: NI = 0
    • 1048 to 4189: NI = 13.25% * 3141 = 416.1825
    • over 4189: NI = 3.25% * 13240 = 430.30

    total NI = 846.4825 * 12 = 10157.79, rounded to 10158


    Remaining = 209148 - 74049 - 10158 = 124941

    How did the reference solution get 124942?

  • Custom User Avatar
    • strictEqual instead of deepEqual

    • duplicate to all time manipulation katas (u can type time in kata search bar and find similar ones)

  • Custom User Avatar

    Mike or Mark?

  • Custom User Avatar

    There's a problem with tests or something is really badly explained in the description. For example, in many tests we have 61305790721611580 in the sequence. This number is not part of the Fibonacci sequence. However tests seem to ignore it and expect other results.
    For example :

    [
          3416454622906707,     5527939700884757,
          8944394323791464,    14472334024676220,
         23416728348467684,    37889062373143900,
         61305790721611580,    99194853094755490,
          2111485077978050,   160500643816367070,
        259695496911122560,   420196140727489660,
        679891637638612200,  1100087778366101900,
       1779979416004714000,  2880067194370816000,
       4660046610375530000,  7540113804746346000,
      12200160415121877000, 19740274219868226000
    ]
    

    wants 2111485077978050.

    [
         23416728348467684,     37889062373143900,
         61305790721611580,     99194853094755490,
        160500643816367070,    259695496911122560,
        420196140727489660,    679891637638612200,
         14472334024676220,   1100087778366101900,
       1779979416004714000,   2880067194370816000,
       4660046610375530000,   7540113804746346000,
      12200160415121877000,  19740274219868226000,
      31940434634990100000,  51680708854858330000,
      83621143489848430000, 135301852344706760000
    ]
    

    wants 308061521170129.

    My code returns 61305790721611580 since it's the first element not in the Fibonacci sequence or not in order. However there are several of them, and it contradicts the description (only 1 inccorect number will be in it).

  • Custom User Avatar

    You can use any fibonacci-like sequence (S(n)=S(n-1)+S(n-2)), .e.g:

    • 0,1,1,2,3,5,8,13,21,... (classic fibonacci)
    • 2,1,3,4,7,11,18,29,47,... (lucas)
    • 36,7,43,50,93,143,236,...
    • 13,17,30,47,77,...
    • ...