Skip to content

Instantly share code, notes, and snippets.

@Cee
Created August 4, 2014 08:25
Show Gist options
  • Select an option

  • Save Cee/9c1ab0d57f4b53159268 to your computer and use it in GitHub Desktop.

Select an option

Save Cee/9c1ab0d57f4b53159268 to your computer and use it in GitHub Desktop.
NQueens
from itertools import permutations
import hashlib
n = 9
cols = range(n)
for vec in permutations(cols):
if (n == len(set(vec[i] + i for i in cols))
== len(set(vec[i] - i for i in cols))):
s = "zWp8LGn01wxJ7"
for x in vec:
a = x + 1
s = s + str(a)
s = s + "\n"
new = hashlib.sha1(s).hexdigest()
if (new == "e48d316ed573d3273931e19f9ac9f9e6039a4242"):
print vec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment