I am trying to solve this problem, but i get wrong answer all the time. I wrote simple JS script to generate tests for this problem and my solution gives exactly the same answer (yes, all numbers are uppercase…). I have no idea what’s wrong with it.
Below the node.js script. When i run my solution with
./convert < tests.txt > ans2.txt ans.txt and ans2.txt are identical.
let tests = 100000;
let num = Math.floor(Math.random()*1000000000)+1;
let baseFrom = Math.floor(Math.random()*35)+2;
let baseTo = Math.floor(Math.random()*35)+2;
out+=num.toString(baseFrom).toUpperCase()+" "+baseFrom+" "+baseTo+"\n";