There’s an example program that produces the above output, (which disallows replacements) and can be extended to any number of parameters:

https://frinklang.org/fsp/colorize.fsp?f=gradingProblem.frink

]]>ABCD 0

ABDC 1

ACBD 1

ACDB 2

ADBC 2

ADCB 3

BACD 1

BADC 2

BCAD 2

BCDA 2

BDAC 3

BDCA 3

CABD 2

CADB 3

CBAD 3

CBDA 4

CDAB 4

CDBA 4

DABC 2

DACB 3

DBAC 4

DBCA 4

DCAB 4

DCBA 5

These are interesting and have good properties: they allow all of the scores from 0 (all correct) to 5, with the only answer scoring 5 to be the total reversal DCBA. If only one pair are swapped (like BACD), the score is 1.

I think that this scoring method would be acceptable for use as a grading system.

]]>A better metric might be to use Levenshtein-Damerau edit distance, as it allows transpositions to be taken into account (it’s a bit trickier to implement in a rigorous way that preserves its usability as a metric.)

ABCD 0

ABDC 2

ACBD 2

ACDB 2

ADBC 2

ADCB 2

BACD 2

BADC 3

BCAD 2

BCDA 2

BDAC 4

BDCA 3

CABD 2

CADB 4

CBAD 2

CBDA 3

CDAB 4

CDBA 4

DABC 2

DACB 3

DBAC 3

DBCA 2

DCAB 4

DCBA 4

Obviously, this isn’t a great metric because even values that are totally reversed (e.g. DCBA) score the same as CDAB which at least has two pairwise elements in the correct order. I should implement Levenshtein-Damerau and see if its results make more sense.

]]>Very cool. Thanks for sharing, Alan!

]]>This algorithm is commonly used in spell-checkers to suggest ‘likely’ substitutions. You could even use this algorithm to grade how ‘wrong’ a word was spelled, by quantifying the number of edits required to make it correct.

]]>I agree that this kind of problem would probably make a better in-class activity, maybe a fun group task.

]]>And no, the students didn’t have calculators here. Although knowing how to use a calculator to evaluate log_2(10) does require some skill!

]]>T. Nadji

]]>