So I have a brain teaser that goes like this:
There's a school that awards students that, during a given period, are never late more than once and who don't ever happen to be absent for three or more consecutive days. How many possible permutations with repetitions of presence (or lack thereof) can we build for a given timeframe that grant the student an award? Assume that each day is just a state On-time, Late or Absent for the whole day, don't worry about specific classes. Example: for three day timeframes, we can create 19 such permutations with repetitions that grant an award.
So I thought about it like that: first, we narrow down our possible space of solutions. We know that there are $2^n$ possible permutations with repetitions with no being late at all (cause then each of the $n$ days is just On-time or Absent) and $n\cdot2^{n-1}$ permutations with repetitions with exactly one Late state.
And here comes the hard part - we now have to subtract all the permutations with repetitions which hold 3 consecutive Absent days, 4 consecutive Absent days and so on. At first, I thought about something like that: there are $n - (k-1)$ ways to fit the $k$-day consecutive absency in a $n$-day timeframe with no Late states. Then, I fiddled with finding a formula for $k$-day consecutive absency for timeframes with exactly one Late state and I even started to find some kind-of-working-ish formulas like $2\cdot 3^{(n-k-1)}$ for 3-day consecutive absencies in timeframes with exactly one Late state but it shortly followed that (a) my reasoning was flawed, (b) I couldn't come up with anything generalised for $k$-day absencies and (c) I realized that both for this and for my $n - (k-1)$, I have to also keep in mind all the possible combinations the remaining days may take (for example, all can be On-time but also every second can be Absent, there can be more than one 3-day absency and so on) and all of these things we have to subtract.
I guess I went way too deep with it and surely there has to be some less twisted solution. How should I go about it?
Try building a recurrence relation. There are six distinct states that we want to track: the student can either have 'used' their late date or not, and there can be 0, 1, or 2 consecutive absent days at the end of the interval we're looking at. So let's use the labels e.g. $f_{p0}(n)$ ($p$ for $p$erfect) for the number of strings of days of length $n$ that have no tardies and end with a non-absent day, $f_{p1}(n)$ the number of strings of days, that have no tardies and end with exactly one absence, $f_{t0}(n)$ the number of strings of days that have used the tardy date and end with no absences, etc. Then (for instance) $f_{p2}(n)=f_{p1}(n-1)$ because we uniquely know the end of the string (it's an absence) and we know uniquely the string before that (it's a string of $n-1$ days with no tardies that ends in one absence). Similarly, $f_{p0}(n)=f_{p0}(n-1)+f_{p1}(n-1)+f_{p2}(n-1)$ because we know the last day is a non-absence (and there are no tardies) but the string before that point could end in anything (as long as there are no tardies in that substring).
From here, you could go on to build a generating function and find an exact formula for the result; I would be surprised if there's a very clean explicit formula (although there's likely a binomial sum similar to the one for the Fibonacci numbers), but the generating function should give you an explicit formula at least.