37 lines
885 B
Python
37 lines
885 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
file = "./input.txt"
|
|
from time import time
|
|
start_time = time()
|
|
|
|
def check_triple(triple:list[int])->bool:
|
|
triple=sorted(triple)
|
|
if triple[0]+triple[1] > triple[2]:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def read_input(filename:str)->list[list[int]]:
|
|
out = []
|
|
input_file = open(filename, "r")
|
|
for line in input_file:
|
|
line = line.strip()
|
|
if line == "":
|
|
continue
|
|
else:
|
|
out.append(list(map(int,line.split())))
|
|
input_file.close()
|
|
return out
|
|
|
|
if __name__ == "__main__":
|
|
sol = 0
|
|
data = read_input(file)
|
|
for l in range(0,len(data),3):
|
|
for r in range(3):
|
|
if check_triple([data[l][r],data[l+1][r],data[l+2][r]]):
|
|
sol += 1
|
|
|
|
|
|
print(f"Solution - Part2: {sol}")
|
|
print(f'Runtime: {time()-start_time:.4f} s') |