1.py 356 B

1234567891011121314151617
  1. import util
  2. def sliding_window(input, size=1):
  3. count = 0
  4. current = input[0:size]
  5. for i in input[size:]:
  6. next = current[1:] + [i]
  7. if sum(next) > sum(current):
  8. count += 1
  9. current = next
  10. return count
  11. input = util.get_input("1.input", int)
  12. print(sliding_window(input, 1))
  13. print(sliding_window(input, 3))