Solve 2016 days 2 and 3.
This commit is contained in:
21
2016/d3.py
Normal file
21
2016/d3.py
Normal 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)
|
||||
Reference in New Issue
Block a user