advent-of-code

advent of code attempts
git clone git://bvnf.space/advent-of-code.git
Log | Files | Refs

1.py (349B)


      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
#!/usr/bin/python

import sys

if len(sys.argv) < 2:
    print(f"usage: {sys.argv[0]} datafile")
    exit(1)


i = 0
prev = 0
numlarger = 0

for line in open(sys.argv[1], "r"):
    i += 1
    if i == 1:
        continue
    line = int(line)
    if line > prev:
        numlarger += 1
    prev = line

print(f"of {i} lines, {numlarger} are greater")