Skip to content

Instantly share code, notes, and snippets.

@pbassut
Last active September 16, 2015 14:07
Show Gist options
  • Save pbassut/7b3614d2d1d15afc8ee9 to your computer and use it in GitHub Desktop.
Save pbassut/7b3614d2d1d15afc8ee9 to your computer and use it in GitHub Desktop.
Exercise 1
def count(numbers):
result = []
for index, each in enumerate(numbers):
cpy = list(numbers)
del cpy[index]
result.append(reduce(lambda x, y: x * y, cpy))
return result
assert count([1, 2, 3, 4]) == [24, 12, 8, 6]
assert count([4, 3, 2, 1]) == [6, 8, 12, 24]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment