Ad
  • Default User Avatar

    New to codewars, so I'm not sure where to post this exactly. My code passed all test but actually shouldn't.

    Here is a testfield that is not correct, but my code sees it as fine:

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

    There are 4 destroyers and the battleship is right next to destroyer.
    This is a specific 'exploit' to my code, since this can only happen when a smaller ship is placed right next to a bigger ship, but two fields down. There is an easy fix for my code. But I wondered why it passed and realized that this is a very specific case that probably doesn't show up often in the random tests.