Skip to content

Instantly share code, notes, and snippets.

@raeq
Created August 12, 2020 19:20
Show Gist options
  • Save raeq/d87d6294987a1146fd0d4935b47d7781 to your computer and use it in GitHub Desktop.
Save raeq/d87d6294987a1146fd0d4935b47d7781 to your computer and use it in GitHub Desktop.
Obfuscated Python lists using map and reduce.
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