Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def neighbouringElements(a)
- match = 0
- x_length = a.length
- y_length = a[0].length
- x = 0
- y = 0
- while (x < x_length)
- while (y < y_length - 1)
- if a[x][y] == a[x][y + 1] then
- match = match + 1
- end
- y = y + 1
- end
- x = x + 1
- y = 0
- end
- x = 0
- y = 0
- while (y < y_length)
- while (x < x_length - 1)
- if a[x][y] == a[x + 1][y] then
- match = match + 1
- end
- x = x + 1
- end
- x = 0
- y = y + 1
- end
- return match
- end
Advertisement
Add Comment
Please, Sign In to add comment