Capgemini Engineering interview question

program for pattern detector for FSM