constraintAllDifferent.frink

Download or view constraintAllDifferent.frink in plain text format


/** This is a tester for Frink's "all different" constraint */

n = 4
if length[ARGS] > 0       // Parse command-line argument
   n = parseInt[ARGS@0]

solver = newJava["frink.constraint.ConstraintSolver"]
q = new array
for i = 0 to n-1
   q@i = solver.makeIntRangeVariable[0,n-1]

solver.allDifferent[toVector[q]]

listener = newJava["frink.constraint.PrintingSolutionListener"]
//listener.setFirstOnly[true]  // Comment this in to find only one solution.
solver.solve[listener]


Download or view constraintAllDifferent.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20145 days, 5 hours, 56 minutes ago.