Hi,
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 out=tests+"\n";
let answers='';
for(let i=0;i<tests;i++)
{
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";
answers+=num.toString(baseTo).toUpperCase()+"\n";
}
const fs=require('fs');
fs.writeFileSync('tests.txt',out);
fs.writeFileSync('ans.txt',answers);