From 24d3faa085daa1823178fb5cd2ccc4d0453e1d2c Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Sun, 22 Sep 2024 21:55:53 -0300 Subject: [PATCH] Solve Friends of Habay in python --- solutions/beecrowd/2136/2136.py | 20 +++++++++++++++++ solutions/beecrowd/2136/in.txt | 26 +++++++++++++++++++++ solutions/beecrowd/2136/out.txt | 17 ++++++++++++++ solutions/beecrowd/2136/problem.md | 36 ++++++++++++++++++++++++++++++ solutions/beecrowd/2136/tags.txt | 1 + 5 files changed, 100 insertions(+) create mode 100644 solutions/beecrowd/2136/2136.py create mode 100644 solutions/beecrowd/2136/in.txt create mode 100644 solutions/beecrowd/2136/out.txt create mode 100644 solutions/beecrowd/2136/problem.md create mode 100644 solutions/beecrowd/2136/tags.txt diff --git a/solutions/beecrowd/2136/2136.py b/solutions/beecrowd/2136/2136.py new file mode 100644 index 00000000..4ec11723 --- /dev/null +++ b/solutions/beecrowd/2136/2136.py @@ -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) diff --git a/solutions/beecrowd/2136/in.txt b/solutions/beecrowd/2136/in.txt new file mode 100644 index 00000000..7e713de3 --- /dev/null +++ b/solutions/beecrowd/2136/in.txt @@ -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 diff --git a/solutions/beecrowd/2136/out.txt b/solutions/beecrowd/2136/out.txt new file mode 100644 index 00000000..65cb13e0 --- /dev/null +++ b/solutions/beecrowd/2136/out.txt @@ -0,0 +1,17 @@ +Ana +Carlos +Felipe +Frederico +Jessica +Julia +Luana +Maria +Beatriz +João +Mariane +Mateus +Ricardo +Tiago + +Amigo do Habay: +Frederico diff --git a/solutions/beecrowd/2136/problem.md b/solutions/beecrowd/2136/problem.md new file mode 100644 index 00000000..0e44a9b3 --- /dev/null +++ b/solutions/beecrowd/2136/problem.md @@ -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. diff --git a/solutions/beecrowd/2136/tags.txt b/solutions/beecrowd/2136/tags.txt new file mode 100644 index 00000000..67e7cf51 --- /dev/null +++ b/solutions/beecrowd/2136/tags.txt @@ -0,0 +1 @@ +data structures and libraries, sorting