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.159 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.158 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.157 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.156 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.155 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.154 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.153 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.152 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.151 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.150 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.149 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.148 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.147 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.146 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.145 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.144 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.143 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.142 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.141 tracks/javascript/exercises/matrix/example.js
trackler-2.2.1.140 tracks/javascript/exercises/matrix/example.js