Skip to content

New Solution#50

Open
Aamooum wants to merge 4 commits intobellaj:masterfrom
Aamooum:xbranch
Open

New Solution#50
Aamooum wants to merge 4 commits intobellaj:masterfrom
Aamooum:xbranch

Conversation

@Aamooum
Copy link

@Aamooum Aamooum commented Oct 24, 2025

I created a simulation program to test different strategies and find the best way to maximize the number of guests who drink water fairly, even when some guests act selfishly.

abstraction :

This simulation models fair resource sharing among guests with dynamic and unpredictable behavior. Since the requirements do not specify how cups should be divided or whether guests agree to share, we assume all guests mutually agree to divide 2 cups equally among themselves. We also assume cups can be realistically divided among all guests. Under this agreement, the first cup flows left-to-right and the second cup flows right-to-left, allowing each guest to drink twice in ideal conditions. The program simulates guests with two behavioral types: "good" (fair sharers) and "bad" (selfish). Guests can randomly change their mindset during each round, and bad guests can choose to drink all or partially share. Additionally, only bad guests can change seats strategically to maximize their intake. Initial simulations without enforcement showed poor fairness rates (~54% for 7 guests, ~38.5% for 14 guests) due to seat-changing exploitation. To address this, we implemented a collective ban system where all guests act as enforcers (This system prevents a guest from lying or assigning a drink to the wrong person. The cup's water level is visible to everyone, and the guest making an accusation must provide clear proof. If the amount of water left is less than the number of people who have not yet drunk, it will be obvious that someone has cheated, and that person will be banned. Furthermore, the system is designed to account for selfish behavior, making it possible to identify individuals who attempt to drink more than their share.) if any guest drinks more than their agreed share or drinks entire cups, all other guests detect and vote to ban them. This social enforcement mechanism is feasible for smaller groups (N ≤ 14) where all guests can observe violations and communicate. The banned guest is then excluded from drinking. The system reallocates cups from banned guests to non-banned participants, maximizing resource usage. Results improved significantly: with seat changes and collective bans enabled, fairness increased from 54.7% to 58.8% for 7 guests and from 38.5% to 43.0% for 14 guests. However, perfect fairness (100%) remains unattainable due to inherent selfishness. The collective ban system demonstrates that community-based rule enforcement provides a practical balance between fairness and feasibility in shared resource scenarios.It is important to note that there are additional scenarios and loopholes that selfish guests could exploit; however, many more strict rules can be implemented to prevent these behaviors and further improve fairness.

Scenario | 7 Guests | 14 Guests
No ban, no seat changes | 66.3% | 61.9%
No ban, with seat changes | 54.7% | 38.5%
Ban, no seat changes | 67.2% | 61.1%
Ban, with seat changes | 58.8% | 43.0%

So in conclusion, adding strict rules can increase the number of guests who get to drink water. However, since there is always a high probability that some guests will act selfishly and disrupt fairness, the percentage can improve but will never reach 100% — unless every guest remains good and never changes their mindset to become bad.

I created a graph with AI to illustrate this. The repository also contains additional information and the program's source code in the commit .

I am really interested in knowing your opinion on this solution.

@Aamooum Aamooum closed this Oct 24, 2025
@Aamooum Aamooum reopened this Oct 24, 2025
Ethereumx and others added 4 commits October 25, 2025 02:26
Signed-off-by: Aamooum <younes.aamoum10@gmail.com>
Signed-off-by: Aamooum <younes.aamoum10@gmail.com>
Signed-off-by: Aamooum <younes.aamoum10@gmail.com>
Signed-off-by: Aamooum <younes.aamoum10@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants