readings[i] is the reading for hour i.
A *cooling spell* is a contiguous stretch of one or more hours in which every reading is exactly one degree below the reading before it. The first hour of a stretch is exempt, so any single hour is a cooling spell too.
Return the number of cooling spells in the log.readings=[5, 4, 3, 7, 6] → 9
The run 5, 4, 3 gives 6 stretches: three single hours, [5, 4], [4, 3] and [5, 4, 3]. The run 7, 6 adds 3 more, for 9 in total.
readings=[2, 2, 1] → 4
The valid stretches are [2], [2], [1] and [2, 1] from the second and third hours. The first two hours have no drop at all, so they do not form a spell.
readings=[9] → 1
readings=[5, 4, 3, 7, 6]
9
Run checks the first 3 tests in your browser. Submit checks all 119 tests on the server, hidden ones included.