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

    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

    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