1
0
Fork 0

Puzzle du 3 décembre 2016

This commit is contained in:
Lucidiot 2017-12-06 13:29:33 +01:00
parent 54c54d264a
commit fdc6510980
No known key found for this signature in database
GPG Key ID: C31F0484107D03EC
2 changed files with 11 additions and 0 deletions

5
2016/3/triangle.py Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env python3
import sys, re
regex = re.compile(r'([0-9]+)')
data = [sorted([int(c) for c in regex.findall(line.strip())]) for line in sys.stdin.readlines()]
print(sum(1 for triangle in data if triangle[0] + triangle[1] > triangle[2]))

6
2016/3/triangle2.py Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env python3
import sys, re
from itertools import zip_longest
regex = re.compile(r'([0-9]+)')
data = [zip_longest(*([iter(col)] * 3)) for col in zip(*[[int(c) for c in regex.findall(line.strip())] for line in sys.stdin.readlines()])]
print(sum(sum(t[0] + t[1] > t[2] for t in [sorted(t) for t in col]) for col in data))