aoc

Advent of Code Solutions
git clone git://git.alexkarle.com.com/aoc
Log | Files | Refs | README | LICENSE

a.py (331B) [raw]


      1 #!/usr/bin/env python3
      2 import sys
      3 
      4 depth = 0
      5 horiz = 0
      6 
      7 for l in sys.stdin:
      8     comm, val = l.split()
      9     if comm == "down":
     10         depth += int(val)
     11     elif comm == "up":
     12         depth -= int(val)
     13     elif comm == "forward":
     14         horiz += int(val)
     15     else:
     16         raise Exception(f"bad comm: {comm}")
     17 
     18 print(horiz * depth)