Interview Puzzle: How to find all "bad" worker histories?
This is an interview question. Suppose we represent working histories of workers as strings. Each string consists of N characters;  each character is one of {A -- "absence", L -- "late", and O -- "ok"). The system raises alarm if either there are two "absences" or three subsequent "late". For example: "AOOAO" -- raises alarm, "ALLOL" -- does not.

Write a function (in Java) to generate all strings of size N, which raise alarm.

I would propose to loop over all possible "working history" strings (it is pretty obvious how to generate them) and filter "bad" string with a regular expression.

How would you approach this problem? 
Interview Puzzle: How to find all "bad" worker histories?
===

This is an interview question. Suppose we represent working histories of workers as strings. Each string consists of N characters;  each character is one of {A -- "absence", L -- "late", and O -- "ok"). The system raises alarm if either there are two "absences" or three subsequent "late". For example: "AOOAO" -- raises alarm, "ALLOL" -- does not.

Write a function (in Java) to generate all strings of size N, which raise alarm.

I would propose to loop over all possible "working history" strings (it is pretty obvious how to generate them) and filter "bad" string with a regular expression.

How would you approach this problem? 