?
Im Sinne von http://blip.tv/file/1947373/?bcsicoach
from itertools import permutations
def is_solution(s):
neighbors = [[1, 2, 3],
[0, 2, 4, 5],
[0, 1, 3, 4, 5, 6],
[0, 2, 5, 6],
[1, 2, 5, 7],
[1, 2, 3, 4, 6, 7],
[2, 3, 5, 7],
[4, 5, 6]]
for index, n in enumerate(neighbors):
for i in n:
if abs(s[index] - s[i]) <= 1:
return False
return True
def niceprint(s):
print " ", s[0:1]
print s[1:4]
print s[4:7]
print " ", s[7:8]
print
for p in permutations(range(1, 9)):
if is_solution(p):
niceprint(p)