constraintSorter.frink

Download or view constraintSorter.frink in plain text format


/** This is a tester for Frink's constraint solver for a pseudo-sorter
    algorithm to test the LessThan 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[1, 2n]

for i = 0 to n-2
   solver.greaterThan[q@i, q@(i+1)]

solver.equals[q@0, q@(n-1), n+2]

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


Download or view constraintSorter.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 20217 days, 16 hours, 0 minutes ago.