2 ms·
Just keep them as BCD and add / xor them in parallel, as show here (under Packed BCD Arithmetic / addition): http://www.cs.uiowa.edu/~jones/bcd/bcd.html#packed
by PassTheAmmo 16y ago
Just keep them as BCD and add / xor them in parallel, as show here (under Packed BCD Arithmetic / addition):
http://www.cs.uiowa.edu/~jones/bcd/bcd.html#packed http://www.cs.uiowa.edu/~jones/bcd/bcd.html#packed
Then just keep track if at least one carry was generated instead of checking if the resulting number was a palindrome separately. Should be very fast.