summary refs log blame commit diff stats
path: root/day1.py
blob: 4cfb29280dfe90b4a07dd628c3765e9f8b20e376 (plain) (tree)






































                                         
#!/usr/bin/env python

curr = None
count = 0

with open("day1.txt") as input:
    for line in input:
        line = int(line)
        if not curr:
            curr = line
            continue
        if line > curr:
            count += 1
        curr = line

print(count)


curr = None
count = 0
with open("day1.txt") as input:
    first = int(next(input))
    second = int(next(input))
    third = int(next(input))
    while True:
        if not curr:
            curr = first + second + third
            continue
        if first + second + third > curr:
            count += 1
        curr = first + second + third
        try:
            first = second
            second = third
            third = int(next(input))
        except StopIteration:
            break

print(count)