EWD249 - 81
the next trial sequence, i.e. final digits = 2 are removed and then the last remaining digit is increased by 1. (The operations "extend with zero" and "increase" guarantee that trial sequences are generated in alphabetical order, the solutions, being a selection from them, will then be printed in alphabetical order as well.) The algorithm will start investigating the following trial sequences, those marked by an asterisk will be rejected as "no good":
0
* 00
01
010
* 0100
* 0101
0102
01020
* 010200
010201
0102010
* 01020100
* 01020101
* 01020102
* 0102011
0102012
.........
I found the majority of my students inclined to make a program with the following structure:
"set trial sequence to single zero;
repeat if good then
begin print trial sequence; extend trial sequence with zero end
else
increase trial sequence
until length = 101"
Although a program along these lines produces the correct output, objections can -and to my taste: should- be made against it. The first objections regards the stopping criterion: when a solution of length 100 has been printed, we (knowing the