Skip to content

Instantly share code, notes, and snippets.

@medicalwei
Created January 6, 2011 11:51
Show Gist options
  • Save medicalwei/767803 to your computer and use it in GitHub Desktop.
Save medicalwei/767803 to your computer and use it in GitHub Desktop.
#!/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