# Help with writing an algorithm

I'm not sure if this question fits the forum, and I should mention that I'm not a computer scientist at all—just a regular normal boy with very little coding knowledge. But I wanted to ask if it's possible to automate the sorting of this table to organize each participant by "maximizing" their preferences.

The data I have is a list of players who are my friends, and a few games we want to play (each game has a different set of roles, which I've labeled as A, B, C, etc.). Each game also has different role requirements. For example, Game 1 needs an A, B, and C, while Game 3 just needs A and B.

At the end of the table, I have each participant's game preferences—where they would like to play.

I think I can sort this manually. For example, let's look at Game 1. I can see that John likes this game the most and wants to play as A. Then we go to the second choices: two people like Game 1 as their second option, so we have Luke as C and Lucy as B. So, Game 1 is complete.

I know I can do it manually, but I was wondering if it could be automated and how exactly I could achieve that.

THANKSS

• I think this is a program development question more than a CS one: The specification of the desired output needs work. What is to be "maximized"? Can the preferences be met by choosing more than one game? How does meeting 2 second choices compare to meeting 3 third choices? Commented Aug 13 at 14:36
• If you really can do manually, try to formalize what you would do and—as greybeard says—objective function to optimize and all restrictions. For a small number of players and games even very inefficient algorithm may be still good enough Commented Aug 13 at 17:34