Company: Google
Difficulty: medium
Google operates a large-scale distributed processing system. Two engineers, Alex and Blake, are responsible for completing batches of pending tasks. A processing session follows these rules: In a single operation, the active engineer may complete 1, 2, 3, or 4 task batches. Completing 4 batches in one operation is considered a Mega Batch Completion. Alex starts processing first. Turn Rules If the active engineer completes exactly 1 batch, control is transferred to the other engineer. If the active engineer completes 2, 3, or 4 batches, the same engineer continues processing. The session ends immediately once the total number of completed batches reaches or exceeds L. Alex wants to end the session in style. Specifically, he wants: To be the engineer who performs the final operation that ends the session. That final operation must be a Mega Batch Completion (i.e., complete exactly 4 batches). Your task is to determine the number of valid operation sequences that satisfy these conditions.