Post Reply 
Tripartite Palindromic Partition of Integer (HP 50g) Challenge
02-22-2023, 05:21 PM (This post was last modified: 03-14-2023 05:07 PM by Albert Chan.)
Post: #26
RE: Tripartite Palindromic Partition of Integer (HP 50g) Challenge
(02-22-2023 02:17 PM)Albert Chan Wrote:  Note: to avoid backtracking, we prefer odd digits y ... but, let's ignore this for now.

Here is an example to show the reason for preferring odd y digits.

n = 80818283828586878      // similar to OP example, but not quite.

(n, 17 digits) = (x, 17 digits) + (y+z, both 16 digits)
n - (10^16-1) = 70818283828586879 = x + z

Code:
  7  0  8  1  8  2  8  3  8  2  8  5  8  6  8  7  9
x 6  7  8  1  3  7  9  4(10) 4  9  7  3  1  8  7  6
z    3  0  0  5 -5 -1 -1 -2 -2 -1 -1 -5  5  0  0  3
c 1                               -1

Note that x is not a valid palindrome, and require backtracking to fix.
Top half of x (no center) = 67813794 - 1 = 67813793

[1, 2, 1] ≡ [0, b+2, 1] ≡ [0, b+1, b+1]      // horner's rule with base b, gives same result

To maintain same x+z, x of [4, 10] → [3, 8], required z of [-1, -2] → [-1, -2+11] = [-1, 9]

80818283828586878 = 67813793839731876 + 9999488998849999 + 3005000990005003



(n, 17 digits) = (x, 17 digits) + (y+z, both 15 digits)
n - (10^15-1) = 79818283828586879 = x + z

Code:
  7  9  8  1  8  2  8  3  8  2  8  5  8  6  8  7  9
x 7  9  6  3  6  9  5  7  5  7  5  9  6  3  6  9  7
z       2 -2  2 -7  3 -4  3(-5) 3 -4  3 -7  2 -2  2
c                                    -1

With odd y digits, no backtracking required Smile

80818283828586878 = 79636957575963697 + 979295949592979 + 202030303030202



Another way, still keeping digits(y) odd, n = (x+y) + z

80818283828586878 - 69999999999999996 = 10818283828586882

Code:
    1  0  8  1  8  2  8  3  8  2  8  5  8  6  8  8  2
x   0  8  8  1  3 -3  0 -5 (1)-5  0 -3  3  1  8  8  0
z      2  0  0  5  5  8  8  7  7  8  8  5  5  0  0  2
c   1

80818283828586878 = 58813000100031885 + 19999694949699991 + 2005588778855002
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 05:21 PM



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