1
0
forked from kalmar/DALGLI0
DALGLI0/02-rozwiazanie.js
Kacper Kruczek 7d5bd4857e 02 input fix
2018-07-01 11:35:34 +02:00

30 lines
751 B
JavaScript

let Polynomial = require('./polynomial.js');
let mul, div, gcd;
function parseArray(x) {
let stringResult = "";
result = Array.from(x).filter(x => {
if (x == ' ' || x == '[' || x == ']') return false;
else return true;
}).join('').split(',').map(x => parseInt(x));
return result;
}
let n = parseInt(process.argv[2]);
let p1 = parseArray(process.argv[3]);
let p2 = parseArray(process.argv[4]);
let f = new Polynomial.Class(n, p1);
let g = new Polynomial.Class(n, p2);
mul = Polynomial.multiply(f, g).coefficients;
try {
div = Polynomial.divide(f, g).coefficients
} catch (e) {
console.log(e)
}
try {
gcd = Polynomial.gcd(f, g).coefficients;
} catch (e) {
console.log(e);
}
console.log([mul, div, gcd])