Ad
  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Please explain to me how the following board is valid:

    [[3, 3, 3, 0, 0, 0, 0, 0, 0, 0],
     [2, 2, 0, 0, 0, 0, 0, 0, 2, 0],
     [2, 2, 0, 0, 3, 3, 3, 0, 2, 0],
     [2, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [2, 0, 0, 0, 0, 0, 0, 0, 1, 0],
     [0, 0, 0, 0, 3, 3, 3, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 1, 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, 0, 0, 0]]
    

    You can't, becasue it isn't, ans you can't possibly know that it is without information not given by the problem. "Is the board valid" is not a question you can answer because, as I said in my original comment, just becasue there exists a configuration that can be valid that does not imply that the configuration is valid. Since the problem is to determine if a valid solution exists for a given board the task is not "return true if it has a valid disposition of ships" but rather "return true if it can have a valid disposition of ships" which is a different question entirely.

  • Custom User Avatar

    Not sure why youre so hostile. Please explain to me how you know the board I mentioned in my comment is not the following:

    [[3, 3, 3, 0, 0, 0, 0, 0, 0, 0],
     [2, 2, 0, 0, 0, 0, 0, 0, 2, 0],
     [2, 2, 0, 0, 3, 3, 3, 0, 2, 0],
     [2, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [2, 0, 0, 0, 0, 0, 0, 0, 1, 0],
     [0, 0, 0, 0, 3, 3, 3, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 1, 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, 0, 0, 0]]
    
  • Custom User Avatar

    Well then you aren't testing whether the field is valid becasue you can't possibly know whether the board is intended to be valid. The instructions say the function should "return true if it has a valid disposition of ships" which is not possible to tell given the information here.

    I assume you mean that this should test whether a board can be valid, but that is not what the instructions say.

  • Custom User Avatar

    For a matrix like:

    [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
     [1, 1, 0, 0, 0, 0, 0, 0, 1, 0],
     [1, 1, 0, 0, 1, 1, 1, 0, 1, 0],
     [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [1, 0, 0, 0, 0, 0, 0, 0, 1, 0],
     [0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 1, 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, 0, 0, 0]]
    

    How are you supposed to determine if the top left corner is a group of 4 and a group of 3, or 3 groups of 2, or 2 groups of 3 and 3 singles, etc etc? Is the idea to choose the proper solution? Because while this can be a real solution, in a different configuration it might not be.

  • Custom User Avatar

    None of the solutions pass all tests for Python 3 due to how number precision changed: https://docs.python.org/3/tutorial/floatingpoint.html

    You have to use Python 2.7 to pass this.

  • Custom User Avatar

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

  • Custom User Avatar

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