Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def differentSquares(matrix)
- array = Array.new(10000) {Array.new(4)}
- x = 0
- y = 0
- z = 0
- while (x < matrix.length - 1)
- while (y < matrix.length - 1)
- if matrix[x][y] != nil and matrix[x][y + 1] != nil and
- matrix[x + 1][y] != nil and
- matrix[x + 1][y + 1] then
- array[z][0] = matrix[x][y]
- array[z][1] = matrix[x][y + 1]
- array[z][2] = matrix[x + 1][y]
- array[z][3] = matrix[x + 1][y + 1]
- z = z + 1
- end
- y = y + 1
- end
- y = 0
- x = x + 1
- end
- array = array.uniq
- return array.length - 1
- end
Advertisement
Add Comment
Please, Sign In to add comment