Sha256: 6795a549101154013973666f972aeedf85ead0130a9d207f0a1c192f0365a65b
Contents?: true
Size: 459 Bytes
Versions: 396
Compression:
Stored size: 459 Bytes
Contents
class Matrix attr_reader :rows, :columns def initialize(input) @rows = extract_rows(input) @columns = extract_columns(rows) end private def extract_rows(s) s.split("\n").map do |row| row.split(' ').map(&:to_i) end end def extract_columns(rows) columns = [] rows.each do |row| row.each_with_index do |number, i| columns[i] ||= [] columns[i] << number end end columns end end
Version data entries
396 entries across 396 versions & 1 rubygems