Post Reply 
Tripartite Palindromic Partition of Integer (HP 50g) Challenge
02-22-2023, 02:17 PM
Post: #25
RE: Tripartite Palindromic Partition of Integer (HP 50g) Challenge
(02-22-2023 09:07 AM)Werner Wrote:  How do you know to take x 12 digits and not 13?

If x is 13 digits, n = x + (y+z), y must be 12 digits = 10^12-1
Note: to avoid backtracking, we prefer odd digits y ... but, let's ignore this for now.

n-y = (10^12+110002) - (10^12-1) = 110003 = x+z --> x cannot be 13 digits palindrome.

If we force it anyway, we have a contradiction of x > n (palindrome x, first digit cannot be 0)
Code:
   0  0  0  0  0  0  0  1  1  0  0  0  3
x  1  8                                1
z    -8                               -8
c                                  -1

(02-22-2023 09:07 AM)Werner Wrote:  The '-5' underneath the 6, how do you know it has to be -5 and not 5?

The goal is not to backtrack, whatever digits written all good.

Code:

   7  0  8  1  8  2  8  3  8  4  8  5  8  6  8  7  8  9
x  6  7  7  1  1                          1  1  7  7  6
z     3  1  0  7  ?                       ?  7  0  1  3
c  1

If ? = 5, we required carry, and backtracking(s) to correct for the changes.
Code:

   7  0  8  1  8  2  8  3  8  4  8  5  8  6  8  7  8  9
x  6  7  7  1  0  6                    6  0  1  7  7  6
z     3  1  0  7  6                       6  7  0  1  3
c  1           1

If ? = 5 - 10 = -5, we can just keep going ...
Code:

   7  0  8  1  8  2  8  3  8  4  8  5  8  6  8  7  8  9
x  6  7  7  1  1  7                    7  1  1  7  7  6
z     3  1  0  7 -5                      -5  7  0  1  3
c  1                                  -1

Note that 8 - 6 = 8 - (7-1) --> next z=2, whether we backtrack with carry, or not.
Both setup, unfilled digits are exactly the same. We can easily show this:

Δx = [1, 1, ..., 1, 1] ≡ [0, b+1, ..., 0, b+1]      // horner's rule with base b, gives same result

To maintain same x+z, x of [0, 6] → [1, 7], required z of [7, 6] → [7, 6-11] = [7, -5]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Tripartite Palindromic Partition of Integer (HP 50g) Challenge - Albert Chan - 02-22-2023 02:17 PM



User(s) browsing this thread: 1 Guest(s)