Solve the no connection puzzle: Difference between revisions

Line 1,270:
('E', 'G'), ('E', 'H'), ('F', 'H')]
 
function goodplacementsgoodperm(perm)
for edge in EDGES
goodtrials = Array{Vector{Int},1}()
if abs(perm[edge[1] - 'A' + 1] - perm[edge[2] - 'A' + 1]) < 2
for perm in permutations(PEGS)
goodtrial = true return false
forend edge in EDGES
end
if abs(perm[edge[1] - 'A' + 1] - perm[edge[2] - 'A' + 1]) < 2
true
goodtrial = false
break
end
end
if goodtrial
push!(goodtrials, perm)
end
end
println("Found $(length(goodtrials)) solutions.")
goodtrials
end
 
goodplacements() = [p for permp in permutations(PEGS) if goodperm(p)]
 
const BOARD = raw"""
Line 1,302 ⟶ 1,295:
function printsolutions()
solutions = goodplacements()
println("Found $(length(goodtrialssolutions)) solutions.")
for soln in solutions
board = BOARD
4,105

edits