]> Skullheadx's Git Forge - CCC.git/commitdiff
Create S3.py
authorSkullheadx <704277@pdsb.net>
Wed, 4 Jan 2023 01:31:59 +0000 (20:31 -0500)
committerSkullheadx <704277@pdsb.net>
Wed, 4 Jan 2023 01:31:59 +0000 (20:31 -0500)
Main/Python/2012/S3.py [new file with mode: 0644]

diff --git a/Main/Python/2012/S3.py b/Main/Python/2012/S3.py
new file mode 100644 (file)
index 0000000..6fabc4a
--- /dev/null
@@ -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()