Ad
  • Custom User Avatar

    If you just return True when there are 20 things marked as 1, roughly 50 TCs will pass. Is this normal?

  • Default User Avatar

    i used my solution for the first kata and adjusted it to fit the non adjacency rule . now it's passing all of the tests exepct like 5 of them that are like this example :
    input:
    [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]
    after running the code :
    [4, 3, 1, 0, 0, 0, 0, 0, 0, 0],
    [4, 3, 0, 0, 0, 0, 0, 0, 2, 0],
    [4, 3, 0, 0, 3, 3, 3, 0, 2, 0],
    [4, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [1, 0, 0, 0, 0, 0, 0, 0, 1, 0],
    [0, 0, 0, 0, 2, 2, 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]

    as you can see its prioritizing bigger ships first wich doesnt work in a minority of the cases.
    any suggestions on how i should assign ships when they are next to each other

  • Custom User Avatar

    I am struggling with this kata quite a bit. I have a very verbose and not so elegant solution that seems to be passing the vast majority of test cases.

    Now I think the error that im running into "Must return true if ships are touching" has to do with the priority that i use when removing ships. I start by removing the 4 cells, then 3, and then 2... however I have noticed that there are cases in which there can be multiple possible battleships and cruisers.

    so I guess my question is, is backtracking required to solve this kata?

  • Custom User Avatar

    Python random tests is very bad: return True can pass the random tests after some repeated submissions. See this

  • Default User Avatar

    python, inadequate random tests:

    my incorrect solution often passes tests

    I'd publish and link it but cw doesn't feel like publishing it. it is however my latest submission, so if you click View Solution on this post, that's the incorrect solution.

  • Custom User Avatar

    I do not like that I cannot see the test because the messages I was getting for my failures were never correct, so it was extremely hard to debug, and I eventually gave up on this kata.

    It was telling me things like "must return False if there are diagonals" (my code could not even count diagonals) and "must return True with ships touching," but it did, and it never failed on account of ships touching, so I had no idea what was wrong with my code, and it was just frustrating.

    Is there any way for you to make the tests viewable?

  • Default User Avatar

    I have a very weird error in Ruby:
    [code] dfs(board, size, pieces, visited, context, m, m) # <<-- #<ArgumentError: wrong number of arguments (given 7, expected 5)>

    Method 'dfs' expects 7 arguments, yet the error message states it expects 5. Where does this number come from? This issue suddenly arises in the random tests, the predetermined tests run smoothly.
    I am logging all arguments before the method call, and indeed I'm providing 7 arguments.
    [code] def dfs(board, size, pieces, visited, context, m, k) # <<-- 7 arguments, so why do I occasionally get an error that 5 is expected ..