0

I resolve this question by using kinds of iteration approach of subset sum (https://en.wikipedia.org/wiki/Subset_sum_problem), show my code below in Python 2.7. Wondering if any pure mathematical solution?

Source code in Python 2.7,

'''
# Print all integers that can be obtained as
# the sum of cubes of 2 distinct pairs of integers.

# Example: 12 pow 3 + 1 pow 3 =  1729 = 10 pow 3 + 9 pow 3


# x * x * x + y * y * y = num
# k * k * k + z * z * z = num

# (x,y) != (k, z) != (y, x)
'''
def two_sum(numbers, target):
    r = 0
    i = 0
    j = len(numbers) - 1
    while i<j:
        if numbers[i] + numbers[j] == target:
            r += 1
            i += 1
            j -= 1
        elif numbers[i] + numbers[j] > target:
            j -= 1
        else:
            i += 1
    return r

def find_number():
    cube_numbers = []
    result = []
    for i in range(100):
        cube_numbers.append(i*i*i)
    for i in range(1, 10001):
        r = two_sum(cube_numbers, i)
        if r == 2:
            result.append(i)
    return result

if __name__ == "__main__":
    print find_number()
Lin Ma
  • 183
  • 1
    Why? There is a parameterization of this equation. http://math.stackexchange.com/questions/469151/find-all-integer-solutions-to-diophantine-equation-x3y3z3-w3 – individ Feb 12 '17 at 04:41
  • @individ, I think my question is different. I am working on two cubic number case, but you referred post is for 3 or 4 cubic number case. If you have any advice on my original question, it will be great. – Lin Ma Feb 13 '17 at 04:42

0 Answers0