From f5925dedeb9ba4b906fda591973cb7628f122764 Mon Sep 17 00:00:00 2001 From: Jethro Stapelbroek Date: Tue, 17 Oct 2023 21:26:11 +0200 Subject: [PATCH] Birthday Memorization --- fodelsedagsmemorisering.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 fodelsedagsmemorisering.py diff --git a/fodelsedagsmemorisering.py b/fodelsedagsmemorisering.py new file mode 100644 index 0000000..d3c3c68 --- /dev/null +++ b/fodelsedagsmemorisering.py @@ -0,0 +1,21 @@ +n = int(input()) + +memory = {} +names = [] +for _ in range(n): + name, likes, birthday = input().split() + likes = int(likes) + + if birthday in memory.keys(): + if memory[birthday][1] < likes: + names.remove(memory[birthday][0]) + memory[birthday] = (name, likes) + names.append(name) + else: + memory[birthday] = (name, likes) + names.append(name) + +print(len(memory.keys())) +names.sort() +for name in names: + print(name)