Post Reply 
Tripartite Palindromic Partition of Integer (HP 50g) Challenge
02-17-2023, 07:37 AM
Post: #11
RE: Tripartite Palindromic Partition of Integer (HP 50g) Challenge
Here is another approach, n = x+y+z, greedy search for x, palindromes x >= y >= z > 0

OP example, x start with 8 implied y start with 0, "bad" palindrome. So, we backtrack a bit.
We maxmize x, by first assume no carries (backtrack if necessary).

Code:
  808182838485868788
x 71              17
y  9               9
z   2              2
c 10              1

Maximize x implied y values start with 0 (y=0 → z=6 → c=1 → x=5)

Code:
  808182838485868788
x 715            517
y  90             09
z   26            62
c 101            01

Code:
  808182838485868788
x 7155          5517
y  900           009
z   262          262
c 1010          001

Code:
  808182838485868788
x 71555        55517
y  9000         0009
z   2623        3262
c 10101        0001

Code:
  808182838485868788
x 715559      955517
y  90000       00009
z   26231      13262
c 101010      00001

Code:
  808182838485868788
x 7155596    6955517
y  900000     000009
z   262319    913262
c 1010101    100001

Code:
  808182838485868788
x 71555964  46955517
y  9000000   0000009
z   2623198  8913262
c 10101010  1100001

Code:
  808182838485868788
x 715559640046955517
y  90000000100000009
z   2623198338913262
c 10101010001100001

808182838485868788 = 715559640046955517 + 90000000100000009 + 2623198338913262
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-17-2023 07:37 AM



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