add: day06

This commit is contained in:
starnakin 2023-12-06 06:41:58 +01:00
parent 7a06186409
commit 677f8350a0
3 changed files with 40 additions and 0 deletions

2
2023/day06/example.txt Normal file
View File

@ -0,0 +1,2 @@
Time: 7 15 30
Distance: 9 40 200

19
2023/day06/src/part1.py Normal file
View File

@ -0,0 +1,19 @@
text: str = open("input.txt", "r").read()
_value: int = 1
lines = text.splitlines()
times = [46857582]
distances = [208141212571410]
for start in range(0, len(times)):
distance = distances[start]
time = times[start]
value = 0
for i in range(0, time):
if ((time - i) * i > distance):
value += 1
_value *= value
print(_value)

19
2023/day06/src/part2.py Normal file
View File

@ -0,0 +1,19 @@
text: str = open("input.txt", "r").read()
_value: int = 1
lines = text.splitlines()
times = [46857582]
distances = [208141212571410]
for start in range(0, len(times)):
distance = distances[start]
time = times[start]
value = 0
for i in range(0, time):
if ((time - i) * i > distance):
value += 1
_value *= value
print(_value)