diff options
| author | Walt Mankowski <waltman@pobox.com> | 2020-08-17 20:13:03 -0400 |
|---|---|---|
| committer | Walt Mankowski <waltman@pobox.com> | 2020-08-17 20:13:03 -0400 |
| commit | 0009002a99e654fb6c1f924c9d8e0169b0ffea64 (patch) | |
| tree | 947f10c00cf3323fb3a56c89292b859694610c8c /challenge-074/walt-mankowski/python | |
| parent | fe25e16220e9e1b20432555ee201fc6da121058d (diff) | |
| download | perlweeklychallenge-club-0009002a99e654fb6c1f924c9d8e0169b0ffea64.tar.gz perlweeklychallenge-club-0009002a99e654fb6c1f924c9d8e0169b0ffea64.tar.bz2 perlweeklychallenge-club-0009002a99e654fb6c1f924c9d8e0169b0ffea64.zip | |
python solution for challenge 74 task 1
Diffstat (limited to 'challenge-074/walt-mankowski/python')
| -rw-r--r-- | challenge-074/walt-mankowski/python/ch-1.py | 15 |
1 files changed, 15 insertions, 0 deletions
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) |
