Bonus question: what about checking ordered lists up to cyclic permutations -- i.e. {1,2,3,4,5} = {2,3,4,5,1} = {3,4,5,1,2} etc. ?

Thanks!

This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 10 posting(s) in 1 day

Bonus question: what about checking ordered lists up to cyclic permutations -- i.e. {1,2,3,4,5} = {2,3,4,5,1} = {3,4,5,1,2} etc. ?

Thanks!

See http://webwork.maa.org/wiki/ListAnswers . You should be able to allow cyclic permutations with a custom checker: http://webwork.maa.org/wiki/CustomAnswerCheckers .

Gavin

```
$ans = Compute("{1,2,3}"); # the correct answer
Context()->texStrings;
BEGIN_TEXT
\($ans\) = \{ans_rule(20)\}
END_TEXT
Context()->normalStrings;
ANS($ans->cmp(
requireParenMatch=>1, removeParens=>0, implicitList=>0,
list_checker => sub {
my ($correct,$student,$ans) = @_;
$correct = List(@$correct); # a List from the correct answer
my @student = @$student; # student answer as array
my $n = scalar(@student); # number of elements in student answer
foreach $i (1..$n) {
return $n if $correct == List(@student); # return n entries correct if permutation is correct
push(@student,shift(@student)); # rotate the student answer
}
return 0; # return no entries correct
}
));
```

The `requireParenMatch=>1`

, `removeParens=>0`

, `implicitList=>0`

are to make sure the student types the braces as part of the list (otherwise `(1,2,3)`

or even `1,2,3`

would also be accepted).
Hope that helps.

Davide