#########################################################################################
# Problem: #
# find 2 different ways to express the number 1729 as the sum of 2 cubes #
# *** link to course @ comments *** #
#########################################################################################
#═════ Find All Numbers Which Are Less Than 1800 ( When Cubed ) ════════════════#
CubedNumbers = {}
i = 1
while i ** 3 < 1800:
CubedNumbers [ i ] = ( i ** 3 )
i = i + 1
#═════ Find All Pairs Which Equate To 1729 ( When Added ) ══════════════════════#
AnswersX = []
AnswersY = []
for x in CubedNumbers:
for y in CubedNumbers:
if CubedNumbers [ x ] + CubedNumbers [ y ] == 1729 \
and not y in AnswersX:
AnswersX.append ( x )
AnswersY.append ( y )
#═════ Print Results ═══════════════════════════════════════════════════════════#
for j in range ( 0, len ( AnswersX ) ):
print ( str ( AnswersX [ j ] ) + "^3 + " + str ( AnswersY [ j ] ) + "^3 = 1729" )