@@ -58,23 +58,28 @@ def simulate(self, probe_velocity: Point):
58
58
velocity = probe_velocity
59
59
max_height = self .probe_loc .y
60
60
61
- while not self .in_trench () and self .probe_loc .x <= max ( self .trench_from . x , self . trench_to .x ) and self .probe_loc .y >= max ( self .trench_from .y , self . trench_to . y ) :
61
+ while not self .in_trench () and self .probe_loc .x <= self .trench_to .x and self .probe_loc .y >= self .trench_from .y :
62
62
self .probe_loc = Point (x = self .probe_loc .x + velocity .x , y = self .probe_loc .y + velocity .y )
63
63
max_height = max (max_height , self .probe_loc .y )
64
64
velocity = Point (x = Everything ._drag (velocity .x ), y = velocity .y - 1 )
65
65
# print(self)
66
- # print(velocity)
66
+ # print(velocity, self.probe_loc, self.trench_from, self.trench_to)
67
+ # print(self.in_trench())
67
68
68
69
return self .in_trench (), max_height
69
70
70
71
ev = Everything .read_input (sys .stdin )
71
- # hit, max_height = ev.simulate(probe_velocity=Point(x=6,y=3 ))
72
+ # hit, max_height = ev.simulate(probe_velocity=Point(x=6,y=0 ))
72
73
# print(hit, max_height)
73
74
74
- max_hit = 0
75
- for x in range (- 2 * abs (ev .trench_to .x ), 2 * abs (ev .trench_to .x )):
76
- for y in range (- 2 * abs (ev .trench_to .y ), 2 * abs (ev .trench_to .y )):
77
- hit , max_height = ev .simulate (probe_velocity = Point (x = x ,y = y ))
75
+ hits = set ()
76
+ for x in range (0 , 4 * abs (ev .trench_to .x )):
77
+ for y in range (- 4 * abs (ev .trench_to .y ), 4 * abs (ev .trench_to .y )):
78
+ velocity = Point (x = x ,y = y )
79
+ hit , max_height = ev .simulate (probe_velocity = velocity )
78
80
if hit :
79
- max_hit = max (max_hit , max_height )
80
- print (max_hit )
81
+ hits .add (velocity )
82
+ # for hit in sorted(list(hits)):
83
+ # print(hit)
84
+ print (len (hits ))
85
+ # print(len(hits), hits)
0 commit comments