diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2020-09-29 21:23:29 +0200 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2020-09-29 21:23:29 +0200 |
| commit | 7de8a43add8580e5f34224658970520d989ea77e (patch) | |
| tree | 93aeee1f301ed719041862e902515dd7f12af454 /challenge-080/lubos-kolouch/python/ch-2.py | |
| parent | b4c10c949c9ecade1377baf7f6468a0c0d77bcbe (diff) | |
| download | perlweeklychallenge-club-7de8a43add8580e5f34224658970520d989ea77e.tar.gz perlweeklychallenge-club-7de8a43add8580e5f34224658970520d989ea77e.tar.bz2 perlweeklychallenge-club-7de8a43add8580e5f34224658970520d989ea77e.zip | |
Python solutions Challenge 080 LK
Diffstat (limited to 'challenge-080/lubos-kolouch/python/ch-2.py')
| -rw-r--r-- | challenge-080/lubos-kolouch/python/ch-2.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-080/lubos-kolouch/python/ch-2.py b/challenge-080/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..1496b407d5 --- /dev/null +++ b/challenge-080/lubos-kolouch/python/ch-2.py @@ -0,0 +1,34 @@ +#!/bin/env pythoon +""" +#=============================================================================== +# +# FILE: ch_2.py +# +# USAGE: ./ch_2.py +# +# DESCRIPTION: https://perlweeklychallenge.org/blog/perl-weekly-challenge-080/ +# Challenge #2 +# Count Candies +# +# AUTHOR: Lubos Kolouch +#=============================================================================== +""" + + +def get_candle_count(arr: list): + """ Count the candles """ + + # We need to give 1 candy to everyone + count = len(arr) + + # and then find out number of unique elements as they will be certainly + # bigger than neighbor... -1 (the initial poor one) + + count += len(set(arr)) + count -= 1 + + return count + + +assert get_candle_count([1, 2, 2]) == 4 +assert get_candle_count([1, 4, 3, 2]) == 7 |
