Created
May 18, 2012 05:27
-
-
Save r3/2723335 to your computer and use it in GitHub Desktop.
Project Euler 6
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
"""I took the liberty of changing two variable names that happen to shadow | |
builtin Python functions (sum and str), but the code is otherwise | |
unedited from what the crew produced in the meeting today. | |
""" | |
def squareOfSums(numbers): | |
#Bob | |
n = sum(numbers) | |
return n ** 2 | |
def sum_powers(lst, power): | |
#Ilya | |
series = [x ** power for x in lst] | |
return sum(series) | |
def sumOfBoth(sums, squares): | |
# Jeff | |
result = abs(sums - squares) | |
print result | |
if __name__ == '__main__': | |
SumSquare = sum_powers([x for x in range(1, 101)], 2) | |
SquareSum = squareOfSums([x for x in range(1, 101)]) | |
sumOfBoth(SumSquare, SquareSum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment