[[0, 1, 2], [2, 1, 0], [0, 1, 2]]
What is an easy way to check this matrix, all values in the column are the same?
[[0, 1, 0], [2, 2, 2], [0, 1, 2]]
And then horizontally?
1.
a.map{|row|row[x]}.uniq.size == 1
or
a.transpose[x].uniq.size == 1
2.
a[x].uniq.size == 1
To check if there is a line in which all elements are the same, you can do:
array.any? do |row| row.all? {|item| row[0] == item } end
To check if there is a column, you can first move the array and then do the same.
Source: https://habr.com/ru/post/1788613/More articles:Moving Images in C # - c #How to move JPopup to Glasspane - javaIPhone icon icon without a number - iosWhat is a good OOP visual tutorial? - oopProblem with overlay gcc template - gccHow and where to store a nhibernate session in winforms per request - asp.netRuby Equivalent to Python "_" - pythonPerhaps a port? (gloomy fandandroido) - androidShort Unique Identifiers - language-agnosticWhat version of Visual Studio Express for JScript.NET? - visual-studioAll Articles