From dc77e5aca7f1078eaf4488da14d2165cb8122b97 Mon Sep 17 00:00:00 2001 From: Skullheadx <704277@pdsb.net> Date: Tue, 3 Jan 2023 20:31:59 -0500 Subject: [PATCH] Create S3.py --- Main/Python/2012/S3.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Main/Python/2012/S3.py diff --git a/Main/Python/2012/S3.py b/Main/Python/2012/S3.py new file mode 100644 index 0000000..6fabc4a --- /dev/null +++ b/Main/Python/2012/S3.py @@ -0,0 +1,34 @@ +readings = dict() + +most_frequent = None +second_most_frequent = None + +N = int(input()) +for i in range(N): + R = int(input()) + if R in readings: + readings[R] += 1 + else: + readings[R] = 1 + + if most_frequent is None or ( + readings[R] > readings[most_frequent] or (readings[R] == readings[most_frequent] and R > most_frequent)): + most_frequent = R + +test = [] +for i in readings: + test.append((i, readings[i])) + + +def get_second(a): + return a[1] + + +test.sort(reverse=True, key=get_second) +print(test) +f = test[1][1] +for i in test: + +second_most_frequent = test[1][0] + +print() -- 2.54.0