Last active
August 14, 2016 01:41
-
-
Save jackhftang/8f6f134c1bd9ce0e81544ac97e755e71 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
#!/usr/bin/env python3 | |
# Problem: http://9gag.com/gag/a6Qq368 | |
def ex(*arg): | |
return [ i for i in range(10) if not i in arg ] | |
def c0p0(a,b,c): | |
arr = [] | |
for i in ex(a,b,c): | |
for j in ex(a,b,c,i): | |
for k in ex(a,b,c,i,j): | |
arr.append( (i,j,k) ) | |
return set(arr) | |
def c1p0(a,b,c): | |
arr = [] | |
for i in ex(a,b,c): | |
for j in ex(a,b,c,i): | |
arr.append( (a,i,j) ) | |
arr.append( (i,b,j) ) | |
arr.append( (i,j,c) ) | |
return set(arr) | |
def c0p1(a,b,c): | |
arr = [] | |
for i in ex(a,b,c): | |
for j in ex(a,b,c,i): | |
arr.append( (i,a,j) ) | |
arr.append( (i,j,a) ) | |
arr.append( (b,i,j) ) | |
arr.append( (i,j,b) ) | |
arr.append( (c,i,j) ) | |
arr.append( (i,c,j) ) | |
return set(arr) | |
def c0p2(a,b,c): | |
arr = [] | |
for i in ex(a,b,c): | |
arr.append( (i,c,b) ) | |
arr.append( (c,i,b) ) | |
arr.append( (b,c,i) ) | |
arr.append( (i,a,c) ) | |
arr.append( (c,i,a) ) | |
arr.append( (c,a,i) ) | |
arr.append( (i,a,b) ) | |
arr.append( (b,i,a) ) | |
arr.append( (b,a,i) ) | |
return set(arr) | |
print( c1p0(5,4,8) & c0p0(5,3,0) & c0p2(1,5,7) & c0p1(8,0,6) & c0p1(8,0,6) ) | |
# {(7, 1, 8)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment