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.
data structure starts here :)
no that is not your result. that's what you print. test your function from outside the function (or somehow figure out what the result is and print that)
the sample tests show how it is called and how it is checked
My result is [5454, 1, 65, 2, 65, 4, 34, 4, 6, 5, 5, 5]. I think this is a right result! But system have writtten that is not right result! Why??? I have no idea why???
Python:
While my approach passes the standard tests it fails often in the random tests. The test suite claims that for example for the difference of
A-B = [9, 12, 1, 1, 77, 34, 1, 1, 0, 73, 20, 25, 60, 42, 28, 24, 10, 11, 30, 35, 36, 0, 33, 18, 51, 26, 0, 51, 13, 25, 13, 10, 49, 8, 5, 25, 64, 12, 42, 1, 13, 57, 43, 0, 1, 39, 12, 10, 18, 1, 27, 1, 31, 7, 71, 61, 27, 38, 15, 42, 1, 11]
the optimal solution is 21 thieves fork=77
.As far as I can see from solving this by hand and with a binary division and greedy approach it can be achieved with 20 thieves without breaking the rules. This also corresponds to the heuristic for the lower bound of the
sum(differences)/k
which is 19.5. Am I missing something or are the random tests only sometimes using the optimal solution as K01egA hinted at?This is the best solution and if you have something to tell shut up please ;)
Oh I forgot this rule. Thanks for reminding!
This was a great opportunity to come up with a creative solution!
It’s always interesting to see how others approach the same problem after you’ve solved it.
Thanks for this awesome kata!
very easy kata!
Hint: Just use by simple math formula to count the odd numbers.
C++
It can't be both together. If the function only checks if the array is wave sorted, it shouldn't check if it stays the same.
It's even worse: i've added
at the beginning of my function, and still it returns "The vector content should stay the same". So, my function only runs if the check function fails - and still the vector should stay the same?
This problem can be reduced to the set cover problem, which is NP-hard, looking at size of tests I can assume that reference solution uses some king of greedy approach, which do not guaranty optimal solution.
Example A = [3, 8, 8, 6, 7], B = [2, 2, 3, 5, 6], k = 6. My solution is 3. First thief can take from jars 1 and 4 second from 2, third from 3 and 5
fixed in this fork
Merged
The easiest kyu
done there
Loading more items...