From d5ffbe9c298ca3ac40923a6c793ab22229f2e937 Mon Sep 17 00:00:00 2001 From: Kacper Kruczek Date: Fri, 29 Jun 2018 19:35:57 +0200 Subject: [PATCH] 02 input --- 02-rozwiazanie.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/02-rozwiazanie.js b/02-rozwiazanie.js index cb8660c..10237a3 100644 --- a/02-rozwiazanie.js +++ b/02-rozwiazanie.js @@ -1,10 +1,20 @@ let Polynomial = require('./polynomial.js'); let mul, div, gcd; -console.log(process.argv[2]); + +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 f = new Polynomial.Class([1, 1, 1, 0, 1]); -let g = new Polynomial.Class([0, 1, 1]); +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