Created
May 20, 2014 19:11
-
-
Save jo32/117ab5ec0a3746644865 to your computer and use it in GitHub Desktop.
This file contains 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
from collections import deque | |
from functools import reduce | |
a = deque([9, 6, 6, 6]) | |
b = deque([7, 1, 5, 3]) | |
c = deque([4, 3, 2, 8]) | |
def is_satisfied(a, b, c): | |
avg = (sum(a) + sum(b) + sum(c)) / 4 | |
return reduce(lambda x, i: x and avg == (a[i] + b[i] + c[i]), range(0, 4), True) | |
def find(): | |
for i in range(0, 4): | |
b.rotate(1) | |
for j in range(0, 4): | |
c.rotate(1) | |
if is_satisfied(a, b, c): | |
return (i + 1, j + 1) | |
print(find()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment