Detecting switches in order

Hello
You may start with coding and we will guide you to find a solution.