Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short solution in Creative category for Bulls and Cows by Sim0000
from itertools import permutations
def checkio(data):
def calc(x, y):
bulls = sum(x[i] == y[i] for i in range(4))
return (str(bulls), str(sum(t in y for t in x) - bulls))
possible = [x for x in permutations('1234567890', 4) if all(calc(x, hint[:4]) == (hint[5], hint[7]) for hint in data)]
return ''.join(possible[len(possible) // 2]) if data else '1234'
March 4, 2014
Comments: