Skip to content

Commit 2335207

Browse files
committed
Add somewhat golfed Python solution
1 parent f689615 commit 2335207

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

2021/17/main.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#((lx, ly), (ux, uy)) = ((20, -10), (30, -5))
2+
((lx, ly), (ux, uy)) = ((128, -142), (160, -88))
3+
4+
(max_height, count, x) = (0, 0, 0)
5+
for vx2 in range(99999999):
6+
for vy in range(-(vx2 * vx2), vx2 * vx2):
7+
(vx, x, y, mh) = (vx2, 0, 0, 0)
8+
while not (lx <= x <= ux and ly <= y <= uy):
9+
(x, y, vx, vy) = (x + vx, y + vy, vx - int(vx > 0), vy - 1)
10+
if x > ux or y < ly:
11+
break
12+
mh = max(mh, y)
13+
else:
14+
max_height = max(max_height, mh)
15+
count += 1
16+
if x > 2 * ux:
17+
break
18+
19+
print(max_height)
20+
print(count)

0 commit comments

Comments
 (0)