From: Skullheadx <704277@pdsb.net> Date: Wed, 4 Jan 2023 01:31:59 +0000 (-0500) Subject: Create S3.py X-Git-Url: http://git.skullheadx.com/nixos/static/index.html?a=commitdiff_plain;h=dc77e5aca7f1078eaf4488da14d2165cb8122b97;p=CCC.git Create 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()