system
Given the following post, respond as if you're commenting on Reddit:
human
Was asked for help with a project, may have stepped in to it a bit. Is there an easier implementation than what I'm thinking?

I owe several million favors to a good friend of mine and he was looking for some programming help. Wanted to take the opportunity to help him out for a change so I offered my assistance. My friend plays a lot of DraftKings and other such things and has asked for a "simple" application in Java. 

The basic idea is this. Given a csv of players, he wants it to create up to x (where x is a user input) line ups using those players. He wants the line-ups to conform (not randomly) to an assigned distribution of players, provided in the csv. Ex: If I've got three QBs, I can set it so one QB appears in 50% of my line ups, another appears in 25% and another appears in the remaining 25%. He then wants the system to eliminate the line ups that fall below or above given parameters for salary and output them into a csv. The csv is a standarized draft kings form. 

So my general idea for implementation is this. 

I would use a few classes. A line up class and a player class with a main class driving the action. The main class would read the csv and populate an array of players with the appropriate information. A series of nested for loops would then run through and populate x arrays with players from the player array. 

The issue that I'm seeing is that there are multiple running backs, wide receivers and tight ends allowed in each line up. In addition, there is a FLEX spot which can be any one of a TE, RB or WR. I'm not totally sure how I'd adhere to the distro with that flexibility. My idea was to instead just randomly select the appropriate number of line ups to fit the required distribution and then place the desired player into a valid spot but that sounds hideous in terms of time and scaling. Ex. If a player would appear in 35% of line ups and the desired x was 200, I would randomly select 70 and place the player in one of the spots randomly. 

In addition, to ensure I didn't add someone twice, I'd need to mark the player class with a "used" Boolean or check each spot the player could possibly be in to ensure they aren't there and aren't added twice to the same line-up. That just seems very inelegant but I'm not sure. 

Thoughts? It may be that this is just the simplest way to do what I'm trying to do but I'm looking for more ideas before I start work. Thanks!
gpt
Is there any reason behind wanting x lineups and the fixed distribution?

The problem you describe sounds like a classic optimization problem. Choose a subset of a set which doesn‘t break the constraints and has an optimized output.

If this is the case take a look at linear programming and a solver like gurobi. You just need to parse the csv and let the solver do the work. You could implement a solver yourself but that‘s just wasted time.