lundi 22 octobre 2018

how to find the row with maximum number of 1s in a matrix in ruby?

I have a matrix boolean 2D array and i want to find the the row with maximum number of 1s.

require 'matrix'
 m1 = Matrix[[0,1,1,1],[0,0,1,1],[1,1,1,1],[0,0,0,0]]
print m1 

can anyone help me out

Aucun commentaire:

Enregistrer un commentaire