I’ve started a little side project to try to learn a few new concepts (hopefully in C++ or Python) and I was just hoping for a little help with the start of my idea.
*This is all related to a bigger fantasy basketball project, but I have to start somewhere.
I want to 100 variables (players) and find every combination of 10, that satisfies another condition.
For example; I have 100 players, and I want to find out how many combinations of 10 (no duplicates, and order does not matter (so ABC == CBA), will combine for a certain value (170 pts between the 10), or higher.
I assume there’s a Python library to work this magic for me (which I would love to know about), but really, I’m more interested in how I would go about this using C++.
Thanks for any responses.
Here is some psuedo-code
The idea here is that because you have the players sorted first, at any point while looping over players in the list, all players after must have an equal or lower point total as the current player. This allows you to break out of the current loop if the current player’s points multiplied by the number of remaining spots left on the team is less than the number of points required to meet the minimum.
For example say you have four players on the team so far with 80 points total, that means you have 90 points left to reach the minimum, and there are 6 spots left. The absolute minimum number of points that your next player can have is 15 (since 90 / 6 == 15), so as soon as you reach a player in next loop that has 14 or fewer points, you can break out of that loop.
This should drastically reduce the total number of combinations you need to get, as long as your minimum_total metric is set high enough.