Advent of Code 2016 solutions https://adventofcode.com/2016/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

03.py 400B

123456789
  1. #!/usr/bin/python3
  2. from itertools import chain
  3. with open('data/03.txt', 'r') as file:
  4. tris = [[int(s) for s in l.strip().split()] for l in file.readlines()]
  5. possible = lambda tris: len([1 for t in [sorted(t) for t in tris] if t[0] + t[1] > t[2]])
  6. print("Part one: %s" % possible(tris))
  7. print("Part two: %s" % possible(chain(*[zip(*tris[i:i + 3]) for i in range(0, len(tris), 3)])))