Sha256: 93e3f0d024d719de1d69f4834cac402b21616ea39e2038c9e06d9b09fd23e85f
Contents?: true
Size: 671 Bytes
Versions: 396
Compression:
Stored size: 671 Bytes
Contents
struct Matrix { let rows: [[Int]] let columns: [[Int]] init(_ stringRepresentation: String) { var rows = [[Int]]() var columns = [[Int]]() let rowItems = stringRepresentation.characters.split(separator: "\n") for item in rowItems { let elements = item.split(separator: " ").flatMap { Int(String($0)) } rows.append(elements) } for i in 0 ..< rows[0].count { var column = [Int]() for row in rows { column.append(row[i]) } columns.append(column) } self.rows = rows self.columns = columns } }
Version data entries
396 entries across 396 versions & 1 rubygems