Sample explanation: In that case, N = 22 . The starting position looks like
We first read ``D 1" and the program looks for a zone with three hooks free in a row. Since the rail is empty, we select hooks 0, 1, 2 and we store the cloth on hook 1 (hooks 0 and 2 are separators and remain empty). The rail moves and stops when 2 is in front of the mark. So the position is exactly
A ticket is given and we write ``The launderer gives ticket 0." in the output file. Next we read ``D 3" and we look for an empty zone with 5 hooks, this corresponds to a zone starting at hook 2 (used as a separator), which enables us to store the three clothes on hooks 3, 4, 5; which brings hook 6 in front of the mark:
We write ``The launderer gives ticket 2." in the output file. When the customer asks for ``W 0" the rail comes back to hook 0
and we write ``0 is freed." and ``1 is freed." in the output file. When we get ``D 3" clothes are stored on hooks 7, 8, 9 (6 and 10 are separators)
and we write ``The launderer gives ticket 6." in the output file. The last deposit is ``D 11" which yields to
and we write ``The launderer gives ticket 10." in the output file.