|
-
Sep 21st, 2010, 09:25 AM
#8
Re: Simple to understand, complex to code; help!
I saw that one coming 
So you have two problems: flex positions and flex players. I think you can take the same approach for both problems, which is to iterate through the permutations. That way, for each iteration, you never actually deal with either flex players or flex positions. The downside of this is that it is algorithmically inefficient, since it is an O(nm) algorithm, where n is product of the number of positions each of your players can play (so if everybody can only play 1 position, then n = 1) and m is the product of the number of positions that each starting slot can take (aka 1 * 1 * 1 * 1 * 1 * 2 * 2 = 4). However, since n is typically going to be 1 or 2, and m is also going to be fairly small, the inefficiency is rather trivial in this case.
So here's a general algorithm layout:
Code:
For each permutation of flex players
For each permutation of flex positions
Assign players according to best fit
Measure point total
Retain point total and lineup if this is the highest score so far
That's it. It sounds like you have the inner part of the loop already. All you need to do is put a nested loop around it and iterate over the flex players and positions and you'll get what you want.
Last edited by Lenggries; Sep 21st, 2010 at 09:27 AM.
Reason: typo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|