Created
June 18, 2014 19:27
-
-
Save reox/933b64f84775b9a884da to your computer and use it in GitHub Desktop.
Print out the smallest numbers that are the sum of two cubes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
x = range(1, 20) | |
solutions = {} | |
for a, b in itertools.combinations(x, 2): | |
sol = a ** 2 + b ** 2 | |
if sol in solutions: | |
print("Found a solutions: %d^2 + %d^2 = %d^2 + %d^2 = %d " % (a, b, solutions[sol][0], solutions[sol][1], sol)) | |
solutions[sol] = (a, b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment