This commit is contained in:
@@ -4,20 +4,9 @@ from pathlib import Path
|
|||||||
|
|
||||||
def part_1(input):
|
def part_1(input):
|
||||||
result = 0
|
result = 0
|
||||||
x, y = input[0].rstrip().replace('target area: ', '').replace(
|
_, y = input[0].rstrip().replace('target area: ', '').replace(
|
||||||
'x=', '').replace('y=', '').split(', ')
|
'x=', '').replace('y=', '').split(', ')
|
||||||
x_min, x_max = [int(c) for c in x.split('..')]
|
|
||||||
y_min, y_max = [int(c) for c in y.split('..')]
|
y_min, y_max = [int(c) for c in y.split('..')]
|
||||||
vx_0 = 0
|
|
||||||
min_num_steps = 0
|
|
||||||
while True:
|
|
||||||
vx_0 += 1
|
|
||||||
x_end = vx_0 * (vx_0 + 1) / 2
|
|
||||||
if x_min <= x_end <= x_max:
|
|
||||||
min_num_steps = vx_0
|
|
||||||
break
|
|
||||||
elif x_end > x_max:
|
|
||||||
break
|
|
||||||
max_valid_height = 0
|
max_valid_height = 0
|
||||||
for vy_0 in range(-y_min):
|
for vy_0 in range(-y_min):
|
||||||
vy = vy_0
|
vy = vy_0
|
||||||
|
|||||||
Reference in New Issue
Block a user