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.8.51 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.50 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.49 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.48 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.47 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.46 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.45 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.44 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.43 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.42 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.41 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.40 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.39 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.38 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.37 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.36 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.35 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.34 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.33 tracks/ecmascript/exercises/matrix/example.js
trackler-2.0.8.32 tracks/ecmascript/exercises/matrix/example.js