1
0
forked from kalmar/DALGLI0
DALGLI0/02-rozwiazanie.js
Kacper Kruczek d5ffbe9c29 02 input
2018-06-29 19:35:57 +02:00

29 lines
719 B
JavaScript

let Polynomial = require('./polynomial.js');
let mul, div, gcd;
function parseArray(x) {
result = Array.from(x).filter(x => {
if (x == ' ' || x == '[' || x == ']' || x == ',') return false;
else return true;
}).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(p1);
let g = new Polynomial.Class(p2);
mul = Polynomial.multiply(f, g, 2).coefficients;
try {
div = Polynomial.divide(f, g, 2).coefficients
} catch (e) {
console.log(e)
}
try {
gcd = Polynomial.gcd(f, g, 2).coefficients;
} catch (e) {
console.log(e);
}
console.log([mul, div, gcd])