gradingProblem.frink

/* This is a proposed solution for Patrick Honner's question about scoring the
"correctness" of an ordered list. It uses the Levenshtein-Damerau edit
distance (eliminating outright replacements) to calculate how many
insertions, deletions, and adjacent character swaps it would take to turn
one sequence into the "right" one.

// Generate all permutations of the list in lexicographic order.
for p = opts.lexicographicPermute[]
{// Turn the permuted array back into a string.
alt = join["", p]

// The 1000 here is the replacement cost, made to be higher than the length// of the string, effectively making the algorithm ignore replacements.
score = editDistanceDamerau[alt, correct, 1, 1, 1000, 1]
println["$alt\t$score"]
}