Skip to content

Conversation

andrewandreii
Copy link

This is an algorithm I came up with so it needs to be checked.

Copy link
Member

@Amaras Amaras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the language, but the Gale-Shapley (and not Gale-Shapely) algorithm looks correct, though there are a few weird points I'd like you to clarify. I haven't run it though, so testing is not yet done.

Thanks for your contribution!

if (not (empty $proposals)) {
exit = 0
} else {
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that one took me a while to understand, but it makes sense. You should say that if we didn't find any proposal, the algorithm has finished.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed the condition to be is-empty $proposals (also empty renamed to is-empty) and modified the comment with more explanation of what the algorithm is doing.

if (==s (kind-of $fem-pref[$female]) string) {
for elem $proposals {
men-pref[$elem] = $men-pref[$elem][1..]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand that loop, could you explain it better? No one is married until the end of the algorithm. So... what is that doing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When $female has a pair, $fem-pref[$female] is equal to the male's name, i.e., it's no longer a map but a string. So we need to remove $female from all the males who are in $proposals.

@Amaras Amaras added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Aug 21, 2021
@ntindle
Copy link
Member

ntindle commented Aug 28, 2021

[lang: elvish]

@andrewandreii andrewandreii closed this by deleting the head repository Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) lang: elvish

3 participants