Sha256: 40a12fa04433d3cbb8a7d56317877efe45cccabb7636105faf9bda5069c28923

Contents?: true

Size: 537 Bytes

Versions: 211

Compression:

Stored size: 537 Bytes

Contents

function columnsFromRows(rows) {
  let columns = [];

  rows.forEach((row) => {
    row.forEach((n, index) => {
      columns[index] = columns[index] || [];
      columns[index].push(n);
    });
  });

  return columns;
}

function parseRows(description) {
  return description.split('\n').map((row) => {
    return row.split(' ').map((char) => parseInt(char, 10));
  });
}

class Matrix {
  constructor(description) {
    this.rows = parseRows(description);
    this.columns = columnsFromRows(this.rows);
  }
}

export default Matrix;

Version data entries

211 entries across 211 versions & 1 rubygems

Version Path
trackler-2.0.0.0 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.4.1 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.4.0 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.3.0 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.2.1 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.2.0 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.1.2 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.1.1 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.1.0 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.0.1 tracks/ecmascript/exercises/matrix/example.js
trackler-1.0.0 tracks/ecmascript/exercises/matrix/example.js