q1 = Variable.new("q1", Domain.new((1..4).to_set)) q2 = Variable.new("q2", Domain.new((1..4).to_set)) q3 = Variable.new("q3", Domain.new((1..4).to_set)) q4 = Variable.new("q4", Domain.new((1..4).to_set)) alldiff = AllDifferentConstraint.new([q1, q2, q3, q4]) tup1 = TupleConstraint.new([q1, q2], [[1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]], false) tup2 = TupleConstraint.new([q2, q3], [[1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]], false) tup3 = TupleConstraint.new([q3, q4], [[1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]], false) queens = Problem.new([q1, q2, q3, q4], ConstraintList.new([alldiff, tup1, tup2, tup3])) puts solve(queens)