Ad
  • Custom User Avatar

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

  • Custom User Avatar

    brackets denote choosing between a number of characters in regex. in this case, picking one of "a", "e", "i", "o", "u", "A", "E", "I", "O", or "U".

  • Custom User Avatar

    As long as there exist one valid combination, then the grid is valid.

  • Custom User Avatar

    Not a suggestion. And your solution is O(n^2).

  • Custom User Avatar

    Except that if you read the kata description:

    There must be single battleship (size of 4 cells), 2 cruisers (size 3), 3 destroyers (size 2) and 4 submarines (size 1). Any additional ships are not allowed, as well as missing ships.

    You'll see there is no ship of size 5 and in the example ReagentX used there is no 4 cells ship. If you can fit all those ships, without overlapping, then the board is valid. Overlap is forbidden too:

    The ship cannot overlap, but can be contact with any other ship.

  • Custom User Avatar

    The guy has a point here, how are we supposed to know the difference between an overlap or a if its just laying side by side, for instance:

    0001000
    0001000
    0111110
    0001000
    0001000

    Above You could assume that two (size 5) ships are overlapping or it can be assumed that one(size 5) ship and two(size 2) ships are independent, Because there is no definition of a ship boundary!!

  • Custom User Avatar

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

  • Custom User Avatar

    That's out. What you have done does not guarantee the equality of two words. Try the case where variable word is 'aabc' and one of variable words is 'abbc'.

  • Custom User Avatar

    'I assume you mean that this should test whether a board can be valid'

    Yes, that is what you're supposed to do.

  • Custom User Avatar

    you can't possibly know that it is without information not given by the problem

    pffff... just learn to read, then?

    There must be single battleship (size of 4 cells), 2 cruisers (size 3), 3 destroyers (size 2) and 4 submarines (size 1). Any additional ships are not allowed, as well as missing ships.

  • Custom User Avatar

    Not sure why youre so hostile.

    depends... seems to me you downvoted me 5 times in a row while I was answering to your question/trouble. Does that feel friendly to you?

    Please explain to me how you know the board I mentioned in my comment is not the following:

    that's exactly what I told you before, you didn't correctly understood the task. Somewhat:

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

    -> yes (seems you edited that part while I was answering before). But all the same, that's exactly what you're asked for: the question is "is the board valid", not "where each one of the ships is placed?".

  • Custom User Avatar
    1. seriously...? it's 3 kyus, and a "real" one. Don't expect it to be as easy as the version I. Just read the task and don't mistake it with the other version. This one has nothing in common about the implementation.
    2. Tests are all perfectly correct
    3. they are not "mine", since I'm neither the author nor the python translator.
    4. Did I just dreamt or you downvoted me on the whole page? (people are so stupid, these days...)
        [[1, 2, 2, 0, 0, 0, 0, 0, 0, 0],
         [4, 2*,0, 0, 0, 0, 0, 0, 2, 0],
         [4, 2*,0, 0, 3, 3, 3, 0, 2, 0],
         [4, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [4, 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]]
    

    and OFC, this board is perfectly valid. And OFC it's to you to find the way to match that.

  • Custom User Avatar

    Seems you didn't understand what the task is... Ofc it's up to you (rather your code) to find that case where it works.

  • Custom User Avatar

    Python 3.4.3 and 3.6 work very well for that kata.
    Moreover you don't need float numbers.