From 0009002a99e654fb6c1f924c9d8e0169b0ffea64 Mon Sep 17 00:00:00 2001 From: Walt Mankowski Date: Mon, 17 Aug 2020 20:13:03 -0400 Subject: python solution for challenge 74 task 1 --- challenge-074/walt-mankowski/python/ch-1.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 challenge-074/walt-mankowski/python/ch-1.py (limited to 'challenge-074/walt-mankowski/python/ch-1.py') diff --git a/challenge-074/walt-mankowski/python/ch-1.py b/challenge-074/walt-mankowski/python/ch-1.py new file mode 100644 index 0000000000..7af167d60a --- /dev/null +++ b/challenge-074/walt-mankowski/python/ch-1.py @@ -0,0 +1,15 @@ +from sys import argv +from collections import defaultdict + +a = [int(x) for x in argv[1:]] +target = len(a) / 2 +result = -1 +cnt = defaultdict(int) + +for x in a: + cnt[x] += 1 + if cnt[x] > target: + result = x + break + +print(result) -- cgit