Created
January 6, 2011 11:51
-
-
Save medicalwei/767803 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/python3 | |
import itertools | |
import operator | |
def ab(x,y): | |
a=sum(map(operator.eq,x,y)) | |
b=len(set(x).intersection(y))-a | |
return (a,b) | |
q=list(itertools.permutations(range(10), 4)) | |
while q: | |
f = q.pop(0) | |
(a,b)=tuple(map(int, input(f).split(' '))) | |
q=list(filter(lambda x: ab(x, f)==(a,b), q)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment