# Every positive integer can be written as the sum of 3 palindrome integers. Wha'ts the largest possible palindrome integer for each integer n? [duplicate]

Let n be a positive integer then n = a + b + c for some a, b, and c that are palindrome integers. What is the largest possible integer a for k = 1 to 1_000_000?

Golf this or have the fastest running time.

NOTE: it's NOT the same as this question as I am asking for the largest palindrome component. The question just asks for ANY combination.

## marked as duplicate by Mr. Xcoder, Arnauld, Quintec, Nit, a spaghettoSep 22 '18 at 13:03

• Welcome to PPCG! This is currently off-topic. We're hosting programming challenges that require an objective winning criterion. Also, this is potentially a duplicate of this question. – Arnauld Sep 22 '18 at 12:49
• I should also note that there is no explicit win condition present here. – Don Thousand Sep 22 '18 at 17:41
• Note that duplicate should not be interpreted as exactly the same but rather as trivially portable. – Jonathan Frech Sep 24 '18 at 2:47
• Golf this or have the fastest running time. I think is not a valid winning criterion. – Jonathan Frech Sep 24 '18 at 2:49
• Also, there is a sandbox on the meta site where people can post their potential questions to see what others think of them. A lot of people use it, even really experienced users who have been on PPCG for a long time – dylnan Sep 24 '18 at 4:14

My Julia solution

using Base.Iterators

is_palindrome(n) = begin
dn = digits(n)
all(dn .== reverse(dn))
end

lim  = Int64(1e6)
res = filter(is_palindrome,lim:-1:0)

using DataFrames
lp = DataFrame(k = 1:1_000_000, largest_palindrome = Array{Int64,1}(lim))

# found stores the integers backwardds
ok(lim, res, lp) = begin
found = BitArray(lim)
found .= false
tot = Int128(0)

cap = lim
r = res[1]

for r in res[1:end-1]
bs = res[res .<= (cap - r)]
cs = res[res .<= ceil((cap - r)/2)]

res1 = vec([r + b + c for (b,  c) in product(bs,cs)])

res1 = res1[res1 .<= cap]

for rr in res1
if !found[rr]
lp[rr,:largest_palindrome] = r
tot = tot + r
found[rr] = true
end
end

for i in lim:-1:1
if !found[i]
cap = i
break
end
end
end

(tot, found, lp)
end