Ordered List

Answer is an ordered list

Complete Code

Download file: AnswerOrderedList.pg

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');

Preamble

These standard macros need to be loaded.
@seq = (1, 1);
for $i (2 .. 6) {
    $seq[$i] = $seq[ $i - 1 ] + $seq[ $i - 2 ];
}

$answer_cmp = Compute(join(', ', @seq))->cmp(ordered => 1);

Setup

We create the array @seq with the first two entries. The rest is filled with a for loop. Since the entries in the array @seq do not have commas between them, we create a Perl string $answer that joins the entries of the array @seq by a comma followed by a space ‘,’. Then, we make this string a MathObject by putting Compute() around it.

Since the answer is a MathObject List, which is by default unordered, we must specify that the answer checker use ordered=>1.

BEGIN_PGML
If [`s_1 = [$seq[0]]`], [`s_2 = [$seq[1]]`], and [`s_n = s_{n-1} + s_{n-2}`],
find the first seven terms of this sequence, including [`s_1`] and [`s_2`].
Enter your answer as a comma separated list of numbers.

Sequence = [_]{$answer_cmp}{20}
END_PGML

Statement

This is the problem statement in PGML.
BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.