2021-12-01 15:16:01 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
count := 0
|
2021-12-01 15:44:15 +00:00
|
|
|
windows := [4]int{0, 0, 0, 0}
|
|
|
|
i := 1
|
2021-12-01 15:16:01 +00:00
|
|
|
|
|
|
|
s := bufio.NewScanner(os.Stdin)
|
|
|
|
for s.Scan() {
|
2021-12-01 15:44:15 +00:00
|
|
|
currentWindow := i % 4
|
|
|
|
nextWindow := (i + 1) % 4
|
|
|
|
|
2021-12-01 15:16:01 +00:00
|
|
|
value, _ := strconv.Atoi(s.Text())
|
2021-12-01 15:44:15 +00:00
|
|
|
for j := 0; j < 4; j++ {
|
|
|
|
if j != currentWindow {
|
|
|
|
windows[j] += value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//fmt.Println(value, windows, currentWindow, nextWindow, windows[nextWindow], windows[currentWindow])
|
|
|
|
// skip the first 3 values to populate the windows
|
|
|
|
if i > 3 && windows[nextWindow] > windows[currentWindow] {
|
2021-12-01 15:16:01 +00:00
|
|
|
count++
|
|
|
|
}
|
2021-12-01 15:44:15 +00:00
|
|
|
|
|
|
|
windows[currentWindow] = 0
|
|
|
|
i++
|
2021-12-01 15:16:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(count)
|
|
|
|
}
|