Skip to content

Commit a70126b

Browse files
authored
Update random-point-in-non-overlapping-rectangles.py
1 parent 9d523bf commit a70126b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Python/random-point-in-non-overlapping-rectangles.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ def pick(self):
6060
target = random.randint(0, self.__prefix_sum[-1]-1)
6161
left = bisect.bisect_right(self.__prefix_sum, target)
6262
rect = self.__rects[left]
63-
width = rect[2]-rect[0]+1
64-
height = rect[3]-rect[1]+1
63+
width, height = rect[2]-rect[0]+1, rect[3]-rect[1]+1
6564
base = self.__prefix_sum[left]-width*height
6665
return [rect[0]+(target-base)%width, rect[1]+(target-base)//width]
6766

0 commit comments

Comments
 (0)