Sha256: ca0d0e6dccbe65ff5eda673760d860c0351e7f7c13b67f8a3770116f8cb20a36

Contents?: true

Size: 576 Bytes

Versions: 141

Compression:

Stored size: 576 Bytes

Contents

'use strict';

function columnsFromRows(rows) {
  var columns = [];
  rows.forEach(function (row) {
    row.forEach(function (n, index) {
      columns[index] = columns[index] || [];
      columns[index].push(n);
    });
  });
  return columns;
}

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

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

module.exports = Matrix;

Version data entries

141 entries across 141 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.77 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.76 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.75 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.74 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.73 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.72 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.71 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.70 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.69 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.68 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.67 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.66 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.65 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.64 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.63 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.62 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.61 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.60 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.59 tracks/javascript/exercises/matrix/example.js