Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    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[:]).

  • Custom User Avatar

    At first it was hard to proceed what i need to do to "recover_disk"

  • Custom User Avatar

    fixed

  • Custom User Avatar

    approved after some small changes

  • Custom User Avatar
    • 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)

  • Custom User Avatar

    Python translation. Please, review and approve (the author is inactive).

  • Custom User Avatar

    Don't mutate the input.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Custom User Avatar

    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 the parity array. So, if any other row in the input is damaged, it can be recovered using the last row, which would be the parity.

    But there are several inputs where the last row itself is damaged, like -

    [ [ 0, 0, 0, 1 ],
      [ 1, 1, 1, 0 ],
      [ 0, 1, 0, 0 ],
      [ 1, 0, 1, 0 ],
      [ 0, null, 0, 1 ] ]
    

    and

    [ [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ],
      [ 0, 1, 1, 0, 1, 0, 0, 0, 0, 0 ],
      [ 0, 0, 1, 1, 1, 0, 0, 1, 0, 1 ],
      [ 0, 1, 0, 0, 0, 1, 0, 1, 1, 0 ],
      [ null, 1, null, 0, null, 0, 1, null, 1, null ] ]
    

    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 the parity, should I first be calculating the parity of the entire input, leaving off the damaged array, and then try to recover it?

  • Custom User Avatar
  • Custom User Avatar

    I really enjoyed this kata. Thanks! ;)

  • Custom User Avatar

    Done, I have iterated 50 times the random tests, 157 tests in total. Should be enough.

  • Custom User Avatar
  • Loading more items...