About HacktobeFest 2024 is live. Make your 4 Pull Request here ! Add your own projects, UI/UX Design, Blogs or improve the projects in the repository. Make sure to add your own work.
Added Python Implementation of Gale-Shapley Algorithm for Stable Matching
This pull request introduces a Python implementation of the Gale-Shapley algorithm to solve the Stable Matching problem. The algorithm pairs men and women based on their preference lists to ensure a stable match where no pair would prefer to be with someone else over their current match.
Key Features:Stable Matching Algorithm: Implements the core Gale-Shapley algorithm where each man proposes to women in their preference order, and women accept or reject proposals based on their preferences.
Input Handling: The algorithm takes user input for both men's and women's preferences and processes them.
Dynamic Engagement Updates: Ensures that men and women engage and disengage dynamically based on mutual preferences, leading to a stable solution.
Usage:
User Input: The script prompts users to input the number of men/women and their respective preference lists.
Stable Matches Output: The algorithm returns the stable pairings by printing the engaged couples.
Example:
For 3 men and 3 women:
Women's Preferences: A prefers 1, 2, 3; B prefers 2, 1, 3; C prefers 3, 2, 1.
Men's Preferences: 1 prefers C, B, A; 2 prefers A, B, C; 3 prefers A, B, C.
The algorithm will produce stable matches without any blocking pairs.
Added Python Implementation of Gale-Shapley Algorithm for Stable Matching
This pull request introduces a Python implementation of the Gale-Shapley algorithm to solve the Stable Matching problem. The algorithm pairs men and women based on their preference lists to ensure a stable match where no pair would prefer to be with someone else over their current match.
Key Features: Stable Matching Algorithm: Implements the core Gale-Shapley algorithm where each man proposes to women in their preference order, and women accept or reject proposals based on their preferences. Input Handling: The algorithm takes user input for both men's and women's preferences and processes them. Dynamic Engagement Updates: Ensures that men and women engage and disengage dynamically based on mutual preferences, leading to a stable solution. Usage: User Input: The script prompts users to input the number of men/women and their respective preference lists. Stable Matches Output: The algorithm returns the stable pairings by printing the engaged couples. Example: For 3 men and 3 women:
Women's Preferences: A prefers 1, 2, 3; B prefers 2, 1, 3; C prefers 3, 2, 1. Men's Preferences: 1 prefers C, B, A; 2 prefers A, B, C; 3 prefers A, B, C. The algorithm will produce stable matches without any blocking pairs.