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