Follow the computed execution on the reference input. Advance one step at a time, inspect the changing values and compare your prediction with the final output.
Example input
{
"a": 43,
"b": 8
}
Execution steps
Subtract largest doubled divisor
Computed output
5
JavaScript reference implementation
const solve = ({
a,b
},s)=>{
let x=Math.abs(a),y=Math.abs(b),q=0;
for(let i=30;
i>=0;
i--){
let d=y*2**i;
if(d<=x){
x-=d;
q+=2**i;
s("Subtract largest doubled divisor",{
Remaining:[x],Divisor:[d],Quotient:[q]
})
}
}
return a*b<0?-q:q
};