Ball Bearing Collisions - A proposed New Problem

Back to General discussions forum

CSFPython     2024-09-27 07:49:50

This problem is about keeping track of a very large number of collisions.

Rodion (admin)     2024-09-27 12:04:52
User avatar

Thank you Clive, as it happens, it looks "not very complicated" at first... Let us some time to dive and see... :)

UPD: wow, I've done it - but it took more time and thinking - the puzzle is funny for it allows several approaches and the first I come upon was very good except it didn't allow calculating collisions!

gardengnome     2024-09-28 22:04:46
User avatar

Interesting one, thank you. O(n*log(n)).

gardengnome     2024-09-29 07:50:53
User avatar

Slightly longer code but it is possible to calculate results for all bearings in O(n) overall.

TestUser     2024-09-29 07:54:55
User avatar

My first attempt was O(n*log(n)) and calculating positions/directions for all, but I failed to come up with idea how to calculate collision count :(

gardengnome     2024-09-29 08:04:55
User avatar

Yes, the idea for positions comes quickly but the collision count approach is not as obvious or intuitive (at least to me). I assume your O(n*log(n)) comes from sorting, but we all hopefully learnt here on CodeAbbey about the merge routine from mergesort which allows O(n) for this problem.

Please login and solve 5 problems to be able to post at forum