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.

  • Default 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...

  • Default 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).

  • Default 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.

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Default 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

  • Default User Avatar

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

  • Default 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.

  • Default 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...