Skip to content

Instantly share code, notes, and snippets.

@Neverik
Created May 12, 2018 04:28
Show Gist options
  • Save Neverik/1c914dc7d14c1eb7c083eeaef0e4455f to your computer and use it in GitHub Desktop.
Save Neverik/1c914dc7d14c1eb7c083eeaef0e4455f to your computer and use it in GitHub Desktop.
Bulls and Cows solver, https://repl.it/repls/RelievedMonstrousFiles to run.
ns = [1750, 1602, 3954, 4716]
ans = [(1, 1), (1, 1), (1, 1), (1, 1)]
def bc (a, b):
bs = 0
cs = 0
for i1, i2 in zip(a, b):
if i1 == i2:
bs += 1
elif i1 in b:
cs += 1
return bs, cs
def inner (a):
for t, answer in zip(ns, ans):
if bc([int (i) for i in list(str(n))], [int (i) for i in list(str(t))]) != answer:
return
print(n)
for n in range(10000):
inner(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment