Skip to content

Instantly share code, notes, and snippets.

@r3
Created May 18, 2012 05:27
Show Gist options
  • Save r3/2723335 to your computer and use it in GitHub Desktop.
Save r3/2723335 to your computer and use it in GitHub Desktop.
Project Euler 6
"""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