From ed9e80e7c9c974e7ff6cef320c0a638d8df3f90f Mon Sep 17 00:00:00 2001 From: kleph Date: Thu, 7 Dec 2023 02:44:19 +0100 Subject: [PATCH] 2023 - Day 6 part 2 --- 2023/6/6_2.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 2023/6/6_2.py diff --git a/2023/6/6_2.py b/2023/6/6_2.py new file mode 100644 index 0000000..73e6d6e --- /dev/null +++ b/2023/6/6_2.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# 2023 - Advent Of Code 6 - part 2 + +import re + +#file = 'input_example.txt' +file = 'input.txt' + +races = [] + +with open(file, encoding="utf-8") as f: + times = re.findall(r"\s+(\d+)+\s?", f.readline()) + distances = re.findall(r"\s+(\d+)+\s?", f.readline()) + big_time = int("".join(times)) + print(big_time) + big_dist = int("".join(distances)) + print(big_dist) + +res = 1 +count = 0 +for tpress in range(1, big_time): + nb = tpress * (big_time - tpress) + if nb > big_dist: + count += 1 + # print(f'{tpress}: {nb}') +print(count)