Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

15
Finding all possible pairings (no time complexity restriction)
Post Body

Let's say I have two lists: Actors and Characters. Each list has a length of 9.

Actors: [Actor1, Actor2, Actor3...]

Characters: [Character1, Character2, Character3...]

Each actor also has a preference for the character they want to play.

Example:

Actor1 wants to play Character1, Character2, or Character8

Actor2 wants to play Character4

....

An actor will not get a character that's not in their preferences.

I want to generate all the possible casts, where each actor plays one character. If an actor only has one character as their preference, then they will get that character and none of the casts generated will feature any other actor as that character.

Ideally the final output also won't repeat any casts either.

Pseudocode for an answer is fine, I mostly just need an idea. The complete answer is also fine.

This is a variation of the Exact Cover problem

Author
Account Strength
100%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
21,370
Link Karma
4,243
Comment Karma
17,072
Profile updated: 6 days ago
Posts updated: 3 days ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
6 years ago