A grain cooperative instruments its intake conveyor with an inline moisture sensor at every batch position. As batches roll past, in order, each sensor emits a single positive integer moisture code for its batch. The valve-control firmware watches the codes in sequence and must trigger an emergency shutoff the instant it detects three consecutive batches whose moisture codes are all odd numbers, since that pattern signals a spoilage risk that must be caught before the batches reach storage.
Given the sequence of moisture codes recorded during one intake run, determine whether the shutoff condition ever occurs anywhere in the run.
Line 1: an integer n — the number of batches recorded. Line 2: n space-separated integers, the moisture codes in the order they were recorded.
Print true if some three consecutive batches all have odd moisture codes; otherwise print false.
1 <= n <= 10^5 1 <= code_i <= 10^9
Example 1
Input
5 1 3 5 2 4
Expected
true
Explanation
Batches 1, 2, and 3 have moisture codes 1, 3, 5 — three in a row that are all odd — so the shutoff triggers and the answer is true.
Example 2
Input
6 2 4 6 8 10 12
Expected
false
Explanation
No batch has an odd moisture code at all, so three consecutive odd codes never occur; the answer is false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →