Skip to main content

New answers tagged

5 votes

Moving ball simulation within a donut

resolve_collisions() tests the separation of every pair of balls, so its complexity scales as O(n²). Consider dividing the box into sub-areas, so we only have to ...
Toby Speight's user avatar
  • 88.3k
2 votes

Moving ball simulation within a donut

More Descriptive/Accurate Docstrings Since you have chosen to use docstrings instead of type hints, then try to be more precise is describing what the arguments to the functions are. For example, I ...
Booboo's user avatar
  • 3,666
2 votes

Moving ball simulation within a donut

I don't have any advice about performance, but here are some general coding style suggestions. DRY This expression is used several times: box_size/2 You can set it ...
toolic's user avatar
  • 15.8k

Top 50 recent answers are included