Created
August 12, 2020 19:20
-
-
Save raeq/d87d6294987a1146fd0d4935b47d7781 to your computer and use it in GitHub Desktop.
Obfuscated Python lists using map and reduce.
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
import functools | |
a = [5, 7, 9, 11] | |
b = [1, 20, 30, 40] | |
c = [3, 3, 3, 6] | |
answers = list(map(lambda x, y, z: (x + y) / z, a, b, c)) | |
assert answers == [2.0, 9.0, 13.0, 8.5] | |
summation = functools.reduce(lambda x, next_reduce: x + next_reduce, [2.0, 9.0, 13.0, 8.5]) | |
assert summation == 32.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment