diff options
| author | Michael Manring <michael@manring> | 2025-01-28 11:58:34 +1100 |
|---|---|---|
| committer | Michael Manring <michael@manring> | 2025-01-28 11:58:34 +1100 |
| commit | dee32c6269b93973ec40023bd148ee8df1560cb2 (patch) | |
| tree | c76ed5e77a8cb9cc92b6e137f2116e69ff03633f /challenge-306/pokgopun/python/ch-2.py | |
| parent | 6cb22100d052edd61e088de9a402c4260ebb4391 (diff) | |
| download | perlweeklychallenge-club-dee32c6269b93973ec40023bd148ee8df1560cb2.tar.gz perlweeklychallenge-club-dee32c6269b93973ec40023bd148ee8df1560cb2.tar.bz2 perlweeklychallenge-club-dee32c6269b93973ec40023bd148ee8df1560cb2.zip | |
minor update to avoid unnecessary sorting
Diffstat (limited to 'challenge-306/pokgopun/python/ch-2.py')
| -rw-r--r-- | challenge-306/pokgopun/python/ch-2.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/challenge-306/pokgopun/python/ch-2.py b/challenge-306/pokgopun/python/ch-2.py index 74c73117de..f6d8d9f298 100644 --- a/challenge-306/pokgopun/python/ch-2.py +++ b/challenge-306/pokgopun/python/ch-2.py @@ -51,11 +51,15 @@ def lstelm(ints: Tuple[int]) -> int: lst = list(ints) while True: l = len(lst) - if l == 0: - return 0 - if l == 1: - return lst[0] - lst.sort() + match l: + case 0: + return 0 + case 1: + return lst[0] + case 2: + pass + case _: + lst.sort() d = lst[-2] - lst[-1] if d == 0: lst = lst[:-2] |
