Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
Added solution for problem #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Anks committed Dec 15, 2008
1 parent 732b940 commit 5c50dfd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 009/9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

numbers = range(1, 400) # a & b will be less than 400 each
combinations = ((a, b) for a in numbers for b in numbers)

a = b = c = None
found = False

for combination in combinations:
a, b = combination

ab_squared = a * a + b * b
c = int(math.sqrt(ab_squared))

if c * c == ab_squared and a + b + c == 1000:
print a * b * c
break

0 comments on commit 5c50dfd

Please sign in to comment.