Skip to content

Commit

Permalink
Add corner cases in board to isReachable
Browse files Browse the repository at this point in the history
  • Loading branch information
eloylp committed Nov 17, 2019
1 parent 921a8a0 commit e3011de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func IsReachableNeighbour(board Board, x, y, ox, oy int) bool {
if y+oy > len(board)-1 || y+oy < 0 {
return false
}
if x+ox > len(board[y]) || x+ox < 0 {
if x+ox > len(board[y])-1 || x+ox < 0 {
return false
}
return true
Expand Down
3 changes: 3 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func TestIsReachableNeighbour(t *testing.T) {
{0, 0, -1, 0, false},
{0, 0, 0, -1, false},
{0, 3, 0, 1, false},
{3, 0, 1, 0, false},
{3, 3, 1, 0, false},
{3, 3, 1, 1, false},
}
}

Expand Down

0 comments on commit e3011de

Please sign in to comment.