Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Transposed Matrix by mortonfox
"use strict";
function transposeMatrix(data){
return data[0].map((_, i) => data.map(row => row[i]));
}
var assert = require('assert');
if (!global.is_checking) {
assert.deepEqual(transposeMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[1, 4, 7], [2, 5, 8], [3, 6, 9]], "Square matrix");
assert.deepEqual(transposeMatrix([[1, 4, 3], [8, 2, 6], [7, 8, 3], [4, 9, 6], [7, 8, 1]]), [[1, 8, 7, 4, 7], [4, 2, 8, 9, 8], [3, 6, 3, 6, 1]], "Rectangle matrix");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
May 19, 2017