Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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?
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 neark + 0.5
, where small differences in floating-point arithmetics can make some solutions round up, others down.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.
It appears my solution is off by one. Let's try to work this out by hand:
Yearly tax:
total tax = 74048.6, rounded to 74049
National Insurance:
Monthly Income = 209148 / 12 = 17429
total NI = 846.4825 * 12 = 10157.79, rounded to 10158
Remaining = 209148 - 74049 - 10158 = 124941
How did the reference solution get 124942?
strictEqual
instead ofdeepEqual
duplicate to all time manipulation katas (u can type
time
in kata search bar and find similar ones)Mike or Mark?
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 :
wants 2111485077978050.
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).
You can use any fibonacci-like sequence (
S(n)=S(n-1)+S(n-2)
), .e.g: