I'm working on a programming question that I believe can be solved with combinatorics, but my combinatorics answer appears to be incorrect.
The question is
An attendance record for a student can be represented as a sequence of characters where each character signifies whether the student was absent (A), late (L), or present (P) on that day. The record only contains the following three characters: A, L, P. Any student is eligible for an attendance award if they meet both of the following criteria: (1) The student was absent ('A') for strictly fewer than 2 days total. (2) The student was never late ('L') for 3 or more consecutive days.
For a given $N$ days, how many ways are there for a student to receive a reward?
My approach is that to recognize that we have $n$ position to fill. There are several disjoint cases that satisfy the constraints:
(1) exactly 1 A and 0 L; $\binom{n}{n-1}$ sequences
(2) exactly 1 A and 1 L; $\binom{n}{n-2} * 2!$ sequences
(3) exactly 1 A and 2 L; $\binom{n}{n-3} * 3! / 2!$ sequences
(4) exactly 0 A and 0 L; $1$ sequence
(5) exactly 0 A and 1 L; $n$ sequences
(6) exactly 0 A and 2 L; $\binom{n}{2}$ sequences
For $n = 4$, I obtain that the result is $39$, however, the solution is apparently $43$.
I enumerated all the possible sequences:
(1) APPP, PAPP, PPAP, PPPA
(2) ALPP, LAPP, APLP, LPAP, PALP, PLAP, APPL, LPPA, PAPL, PLPA, PPAL, PPLA
(3) ALLP, LALP, LLAP, ALPL, LAPL, LLPA, APLL, LPAL, LPLA, PALL, PLAL, PLLA
(4) PPPP
(5) LPPP, PLPP, PPLP, PPPL
(6) LLPP, LPLP, PLLP, LPPL, PLPL, PPLL
