Solve the no connection puzzle: Difference between revisions

Content added Content deleted
Line 1,270: Line 1,270:
('E', 'G'), ('E', 'H'), ('F', 'H')]
('E', 'G'), ('E', 'H'), ('F', 'H')]


goodperm(p) = all(e->abs(p[e[1]-'A'+1] - p[e[2]-'A'+1]) > 1, EDGES)
function goodperm(perm)
for edge in EDGES
if abs(perm[edge[1] - 'A' + 1] - perm[edge[2] - 'A' + 1]) < 2
return false
end
end
true
end


goodplacements() = [p for p in permutations(PEGS) if goodperm(p)]
goodplacements() = [p for p in permutations(PEGS) if goodperm(p)]