diff options
author | Christopher Burns | 2010-06-28 23:17:31 -0500 |
---|---|---|
committer | Christopher Burns | 2010-06-28 23:17:31 -0500 |
commit | 1969e862549e935ae587114dbe6c22c3dee1d0cf (patch) | |
tree | e40347d893e2316cb214c227d56a3bedf3839322 /day1 | |
parent | 8e831cf3476e0aae2480d3d1af53bafe4a5dd178 (diff) | |
download | workshops-more-scipy-1969e862549e935ae587114dbe6c22c3dee1d0cf.tar.gz workshops-more-scipy-1969e862549e935ae587114dbe6c22c3dee1d0cf.tar.bz2 workshops-more-scipy-1969e862549e935ae587114dbe6c22c3dee1d0cf.zip |
REF: Minor formatting tweaks in exercise solutions.
--HG--
branch : scipy2010
Diffstat (limited to 'day1')
-rw-r--r-- | day1/exercise/gcd.py | 6 | ||||
-rw-r--r-- | day1/exercise/pytriads.py | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/day1/exercise/gcd.py b/day1/exercise/gcd.py index 41db13d..35d704e 100644 --- a/day1/exercise/gcd.py +++ b/day1/exercise/gcd.py @@ -1,7 +1,7 @@ def gcd(a, b): - if a % b == 0: - return b - return gcd(b, a%b) + if a % b == 0: + return b + return gcd(b, a%b) print gcd(5, 40) print gcd(11, 60) diff --git a/day1/exercise/pytriads.py b/day1/exercise/pytriads.py index caf9137..f93917b 100644 --- a/day1/exercise/pytriads.py +++ b/day1/exercise/pytriads.py @@ -8,10 +8,11 @@ def gcd(a, b): if a % b == 0: return b else: - return gcd(b, a%b) + return gcd(b, a % b) for a in range(3, 101): - for b in range( a+1, 101, 2): - if gcd( a, b ) == 1: + for b in range(a + 1, 101, 2): + if gcd(a, b) == 1: is_ps, c = is_perfect_square((a * a) + (b * b)) - if is_ps: print a, b, c + if is_ps: + print a, b, c |