by Allypost · 4y ago · 0 comments
The easiest way to see this is by typing `9007199254740992 + 1` in your browser's dev console. It should spit out `9007199254740992`. `(Math.pow(2, 53) + 1) == Math.pow(2, 53)` returns true.
That means your program would print invalid output (or rather start looping infinitely) starting at that number (which is much smaller than 2^63) thus disqualifying your solution.
Just change the constant 10000000000000000 in the outer loop to 1000000000000000 (which is 2^49+437050046578688 and well below 2^53), change the filling of the right[] array to
for (let r = 0; r < 10; ++r) {
right.push('000' + itos(r) + '\n')
}
for (let r = 10; r < 100; ++r) {
right.push('00' + itos(r) + '\n')
}
for (let r = 100; r < 1000; ++r) {
right.push('0' + itos(r) + '\n')
}
for (let r = 1000; r < 10000; ++r) {
right.push(itos(r) + '\n')
}
and change the loop that starts "for (let r = 1; r < 1000; ++r) {" to go to 10000 instead of 1000.