Ad
  • Custom User Avatar

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

  • Custom User Avatar
    test case:
    
    [ 1, 0, 0, 0, 0, 1, 1, 0, 0, 0 ],
    [ 1, 0, 1, 0, 0, 0, 0, 0, 1, 0 ],
    [ 1, 0, 1, 0, 1, 1, 1, 0, 1, 0 ],
    [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
    [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ],
    [ 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 ],
    [ 0, 0, 0, 1, 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 ]
    
    reason for fail: Must return false if ships are in contact
    

    These two, are touching diagonally:

    #                v  
    [ 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 ],
    [ 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 ],
    #          ^
    

    Please use markdown formatting next time.

  • Custom User Avatar

    test case:

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

    reason for fail: Must return false if ships are in contact

    I can't see how is there a ship in contact with another ship here. What am I missing? Tis is the only scenario my code is failing.

  • Custom User Avatar

    I created a fork with verbose comments to explain what is going on in this solution.
    I hope I got it right...

  • Custom User Avatar

    Thank's every one for reply I got the problem. It was in checking if a number is Prime or not what I did was check i < Math.sqrt(n) which should have been i <= Math.sqrt(n).

  • Custom User Avatar

    hobovsky that was the first thing that I chacked still no luck , I am probably doing similar silly mistake here, I will try again.

  • Custom User Avatar

    Not a chance because this is also the case where the '1' is not supposed to be tested , for eg (48,2838);

  • Custom User Avatar

    1 is not a prime number. Its probably the problem here.

  • Custom User Avatar

    It seems I have made a mistake. 1 Is not a prime number as I thought.

  • Custom User Avatar

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

  • Custom User Avatar

    Maybe you could tell how much you understand and what makes you confused. Symbol? Syntax? Lib?
    So we can explain it to you in a better way

  • Custom User Avatar

    I can't understand a single thing that is going on here

  • Custom User Avatar

    Sorry, I have missread the Kata.

    It says in the example:

    if j = 5:

    ..C.....m. returns 'Caught!' <-- not more than j characters between

    So actually it is my fault. Sorry for posting it as an issue.

  • Custom User Avatar

    I think there's a problem in Ruby.

    x= .....DC...m......
    j = 3

    it says: Expected: "Caught!", instead got: "Escaped!"

    How can it expect Caught if the 'C' is 4 units away from 'm'? It won't reach the mouse, so my answer should be correct, all other atempt cases my solution passes.

  • Custom User Avatar
  • Loading more items...