As the string is being built up, two things could happen that would instantly prevent the string from qualifying: a second lateness (L) is added, or an absence (A) is added to a string that already ended with two absences, so that this would be the third in a row.
There are six states that a given string could be in as it's in the process of being built up to length 12: it can have zero latenesses or one lateness; and within these categories, have zero, one or two absences at the end.
Punctuality or Lateness reset the Absence counter to zero, but Latenesses are never reset.
Each addition of a character, A, P or L, multiplies the possibilities by 3, but some of these fall off the valid set as explained above.
The sets of figures below show, in the left hand column numbers of strings with no latenesses, and in column two those with one lateness. The three numbers in each group refer to zero, one or two trailing A's (absences). You can see how the initial single A, P or L tally in the first set.
When a second letter is added, the possibility of an A creates a 1 in the one-A category in each column in the next set by carryover from zero A's, and a 1 in the two-A category as a carryover from the one-A category in the previous set. It also creates a 1 in the one-A category in the right column (one L becomes LA). The possibility of a P changes the 1 to a 2 in the top left entry as the sum of PP and AP as the absences get reset. The same happens in the right column as the 3 accounts for LP, PL or AL.
The numbers in the second group add to 8, as LL immediately becomes a disqualified branch.
The transitions from
A D
B E
C F
make the next set:
A+B+C A+B+C+D+E+F
A D
B E
Note that while A and B apprear three times in the next group, C, D and E appear only once each, as state C, ending in two Absences, is lost to validity with a third Absence; D and E are lost via an L; F appears only once, as only a Puncutality will keep it valid, as an Absence would be the third in a row, and a Lateness would be a second lateness.
The table:
1 1
1 0
0 0
2 3
1 1
1 0
4 8
2 3
1 1
7 19
4 8
2 3
13 43
7 19
4 8
24 94
13 43
7 19
44 200
24 94
13 43
81 418
44 200
24 94
149 861
81 418
44 200
274 1753
149 861
81 418
504 3536
274 1753
149 861
927 7077
504 3536
274 1753
The numbers in the last (12th) set add up to 14071, making that the answer. |