Skip to content

Commit

Permalink
Solve Friends of Habay in python
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Sep 23, 2024
1 parent 50eb57b commit 24d3faa
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
20 changes: 20 additions & 0 deletions solutions/beecrowd/2136/2136.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys

registered = set()
amigo = ''

for line in sys.stdin:
if line.strip() == 'FIM':
break

name, answer = line.strip().split()
if len(name) > len(amigo) and answer == 'YES':
amigo = name

registered.add((0 if answer == 'YES' else 1, name))


print('\n'.join(map(lambda x: x[1], sorted(registered))))
print()
print('Amigo do Habay:')
print(amigo)
26 changes: 26 additions & 0 deletions solutions/beecrowd/2136/in.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Ana YES
Luana YES
Frederico YES
Julia YES
Felipe YES
Ricardo NO
Carlos YES
Jessica YES
Maria YES
Ana YES
João NO
Mariane NO
Felipe YES
Carlos YES
Luana YES
Jessica YES
Beatriz NO
Mateus NO
Ana YES
Julia YES
Tiago NO
Frederico YES
Luana YES
Maria YES
Ana YES
FIM
17 changes: 17 additions & 0 deletions solutions/beecrowd/2136/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Ana
Carlos
Felipe
Frederico
Jessica
Julia
Luana
Maria
Beatriz
João
Mariane
Mateus
Ricardo
Tiago

Amigo do Habay:
Frederico
36 changes: 36 additions & 0 deletions solutions/beecrowd/2136/problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
https://judge.beecrowd.com/en/problems/view/2136

# Friends of Habay

Every end of year there is a party in Fantastic Education Institution (FEI).
Early in July, the registration is open to take part in it. At registration, the
user can choose whether to be "O Amigo do Habay" (The Friend of Habay) in the
party or not. The most logical choice would be Yes, because it is a privilege to
be The Friend of Habay, since he is the coolest person in FEI. However, there
are some people who definitely don't want to be The Friend of Habay, and for
unknown reasons.

Only one will be chosen. As a result, many students who chose the option Yes
registered several times to increase their chance of being The Friend of Habay.
The party organizer hired you to organize the website's registration, since
there is a registration spam going on. The criteria to be the chosen one is the
number of letters of the first name, and if there is more than one name with the
same number of letters, wins the one who first registered. The final
organization of the registered users should follow the order of choice (Yes or
No), while respecting the alphabetical order.

Note: No one who chose the option No registered more than once.

## Input

The input consists of a single test case. Each line consists of the user's first
name (no spaces), followed by the option YES (if the user wants to be O Amigo do
Habay, i.e., The Friend of Habay) or NO (if the user doesn't). Read input until
the user enters "FIM" (without quotes).


## Output

Print the registered users in order of choice, respecting the alphabetical
order, then print the winner's name. Print a blank line between the list of
registered users and the winner's name.
1 change: 1 addition & 0 deletions solutions/beecrowd/2136/tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data structures and libraries, sorting

0 comments on commit 24d3faa

Please sign in to comment.