Solve 2016 days 2 and 3.

This commit is contained in:
2024-03-18 18:37:24 -04:00
parent ba80eb7a74
commit f616dbb686
3 changed files with 60 additions and 0 deletions

21
2016/d3.py Normal file
View File

@@ -0,0 +1,21 @@
from lib import *
second = True
data = open(0).read()
res = 0
if not second:
for row in data.splitlines():
a, b, c = list(map(int, row.split()))
if a + b > c and a + c > b and b + c > a:
res += 1
else:
rows = list(map(lambda row: row.split(), data.splitlines()))
for coli in range(len(rows[0])):
for rowi in range(0, len(rows), 3):
a = int(rows[rowi][coli])
b = int(rows[rowi + 1][coli])
c = int(rows[rowi + 2][coli])
if a + b > c and a + c > b and b + c > a:
res += 1
print(res)