Advent of Code 2016 solutions https://adventofcode.com/2016/
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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)])))