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 random tests only check for the second function but not the first
Node 12 should be enabled (Refer this and this for more info)
Python translation. Please, review and approve (the author is inactive).
Don't mutate the input.
This comment is hidden because it contains spoiler information about the solution
Since you haven't solved the problem yet, I'm going to try to give two answers a more vague one without spoilers and a deeper one with spoilers.
To find a solution you need to think of the problem as it would be in reality. You have an array of disks, and parity information is stored as described. Any of those disks can fail, your system needs to be able to recover from the failure of any single disk, otherwise the failure of the last disk becomes a SPOF which is exacly what your algorithm tries to prevent. Try to think of the cleverest way to racalculate any array damaged without resourcing to special cases.
I have a question for the
recoverDisk()
function. I assumed that in the array of arrays given as input to this function, the last row will always be theparity
array. So, if any other row in the input is damaged, it can be recovered using the last row, which would be theparity
.But there are several inputs where the last row itself is damaged, like -
and
Since my algorithm always considers the last row as the
parity
, and tries to recover the data based off of this row, the code fails such test cases.If the last row in
recoverDisk()
is not necessarily theparity
, should I first be calculating theparity
of the entire input, leaving off the damaged array, and then try to recover it?;-)
I really enjoyed this kata. Thanks! ;)
Done, I have iterated 50 times the random tests, 157 tests in total. Should be enough.
Will do
Translation to JS Kumited
https://www.codewars.com/kumite/57ed9755bd793ecdd0000e73?sel=57ed9755bd793ecdd0000e73
Well done. If you can add more random tests will be perfect(use a for loop) ;-)
Fixed it. It was randomizing between 0 and length instead of length-1. Thanks again.
Thanks for the heads up. I'll look into this.
That shift rightwards is clever. I like it.
Loading more items...