Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Skew-symmetric Matrix by Sim0000
"use strict";
function symmetric(matrix) {
let n = matrix.length;
for(let i = 0; i < n; i++){
for(let j = 0; j < n; j++){
if(matrix[i][j] != -matrix[j][i]) return false;
}
}
return true;
}
var assert = require('assert');
if (!global.is_checking) {
console.log('Example:')
console.log(symmetric([
[0, 1, 2],
[-1, 0, 1],
[-2, -1, 0]]))
// These "asserts" using only for self-checking and not necessary for auto-testing
assert.equal(symmetric([
[0, 1, 2],
[-1, 0, 1],
[-2, -1, 0]]), true);
assert.equal(symmetric([
[0, 1, 2],
[-1, 1, 1],
[-2, -1, 0]]), false);
assert.equal(symmetric([
[0, 1, 2],
[-1, 0, 1],
[-3, -1, 0]]), false);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
July 13, 2018