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.
this is five lists:
[[0, 0, 0, 1], [1, None, 0, 1], [0, 1, 1, 1], [1, 1, 1, 1]]
this copies one list
cluster[:]
meaning that the other four are still the same ones
if the tests are showing the list after having allowed you to mutate it then that's not great because it can cause confusing messages that don't add up. buut you're also somewhat deserving of confusion if doing mutation where mutation isn't explicitly what is asked for.
It might be an issue with my code, but one of the fixed tests (total failure) says that the input is different from the real input.
printing cluster at the beginning:
[[0, 0, 0, 1], [None, None, None, None], [0, 1, 1, 1], [1, 0, 1, 1]]
the test says:
"For input: [[0, 0, 0, 1], [1, None, 0, 1], [0, 1, 1, 1], [1, 1, 1, 1]]: "
I just create a copy of the cluster and operate on it (r = cluster[:]).
At first it was hard to proceed what i need to do to "recover_disk"
fixed
approved after some small changes
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
Loading more items...