06-2 fertig
This commit is contained in:
28
06/06-1.py
Normal file
28
06/06-1.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
times = []
|
||||||
|
dists = []
|
||||||
|
|
||||||
|
input_file = open("input", "r")
|
||||||
|
for line in input_file:
|
||||||
|
if line.startswith('Time:'):
|
||||||
|
times = line.strip().split(":")[1].split()
|
||||||
|
if line.startswith('Distance:'):
|
||||||
|
dists = line.strip().split(":")[1].split()
|
||||||
|
input_file.close()
|
||||||
|
|
||||||
|
winning_trys = []
|
||||||
|
for i in range(len(times)):
|
||||||
|
wins = 0
|
||||||
|
for j in range(int(times[i])+1):
|
||||||
|
if (int(times[i])-j)*j > int(dists[i]):
|
||||||
|
wins += 1
|
||||||
|
winning_trys.append(wins)
|
||||||
|
|
||||||
|
print(winning_trys)
|
||||||
|
solution = 1
|
||||||
|
for j in winning_trys:
|
||||||
|
solution *= j
|
||||||
|
|
||||||
|
print(solution)
|
||||||
18
06/06-2.py
Normal file
18
06/06-2.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
tim, dis = 0, 0
|
||||||
|
|
||||||
|
input_file = open("input", "r")
|
||||||
|
for line in input_file:
|
||||||
|
if line.startswith('T'):
|
||||||
|
tim = int(line.strip().split(":")[1].replace(" ", ""))
|
||||||
|
if line.startswith('D'):
|
||||||
|
dis = int(line.strip().split(":")[1].replace(" ", ""))
|
||||||
|
input_file.close()
|
||||||
|
|
||||||
|
wins = 0
|
||||||
|
for j in range(tim + 1):
|
||||||
|
if (tim-j) * j > dis:
|
||||||
|
wins += 1
|
||||||
|
|
||||||
|
print(wins)
|
||||||
2
06/input-ex
Normal file
2
06/input-ex
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Time: 7 15 30
|
||||||
|
Distance: 9 40 200
|
||||||
Reference in New Issue
Block a user