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.
@fran_Cesco: No, that's not the case, read about integer division.
I believe that the test cases have been luckily tailored to allow this solution. 9 mangos that cost 5 each cost 30 in total. But if you apply the above with 8 mangos costing 5 each you should get the same result (you are not taking advantage of 1 free mango) but instead you get a float which makes no sense because the result should always be a multiple of 5.
Pretty sure 95% code-wariors search for a formula in google. Like me who's dumb as rock at math. It's almost imposible to solve it without knowing formula.
I feel that way more often than not on Codewars!
I feel dumb seeing these simple solutions.
Take a look at my solution, if it isn't obvious use pen and paper to draw points.
Nice
can you please exaplin how this works?
I'm not sure what you mean with your question :) While this:
means you drop every third mango from the calculation (because it's free by definition), your snippet -
((quantity / 3 ) * 2) * 2
- is not mathematically equivalent to the former (hint: integer division is not exactly like float division).oooooh. know I get it. You should add this example to the instructions for people like me :)
The shifting value is lower than the array size. But there is no other dependency between these both values.
Shift 2 means, that -77 would be added to 28 and not to -91.
So -49 is correct.
0 would mean:
1 would mean:
2 would mean:
3 would mean:
And another problem. Input:
So algorithm is something like:
And the result is:
[71, 39, 28, -168, 18, 29, -27, -171, 10, 42, -71, 7, -45, 58]
, but test expects:[71, 39, -49, -67, -55, -30, -25, -30, -47, -45, 58]
I can be mistaken, but I guess with
shift = 2
and arrays size = 5, the first 3 elements of the first array must be in the result. So the result array must start with[71, 39, 28...]
, when test expexts[71, 39, -49...]
. Why?Thank you for telling me about the problem!
Now everything is correct with sizes! Thanks!
Loading more items...