Last active
September 16, 2015 14:07
-
-
Save pbassut/7b3614d2d1d15afc8ee9 to your computer and use it in GitHub Desktop.
Exercise 1
This file contains hidden or 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
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