// PRINTS OUT PAIRS (GRADE,ANNOUNCEMENT)
// ANONYMITY CAN BE VERIFIED BY CHECKING
// LANGUAGE EQUIVALENCE WITH SPECIFICATION (grade-spec.txt)
// number of students
//const STUDENTS:= 3;
// grades: 0,1,...,GRADES-1
//const GRADES:=2;
const N := STUDENTS*(GRADES-1)+1;
grade:int%GRADES, out:var%N |-
var%(STUDENTS+1) i;
var%N first;
first:=rand[N];
var%N right;
right:=first;
i:=0;
while(i<STUDENTS) do {
var%N left;
i:=succ(i);
left := if (i=STUDENTS) then first else rand[N];
out := (grade + left) - right;
right := left;
}
:com
// SPECIFICATION TO BE USED WITH grade-impl2.txt
//const STUDENTS:=10;
//const GRADES:=10;
const N := STUDENTS * (GRADES-1) + 1;
grade:int%GRADES, out:var%N |-
var%STUDENTS i;
var%N total;
i:=1;
while(i) do {
total := grade + total;
var%N r;
r := rand[N];
out:=r;
total := total - r;
i:=succ(i)
};
out:= grade + total: com