aboutsummaryrefslogtreecommitdiff
path: root/challenge-306
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-306')
-rw-r--r--challenge-306/pokgopun/go/ch-2.go4
-rw-r--r--challenge-306/pokgopun/python/ch-2.py14
2 files changed, 12 insertions, 6 deletions
diff --git a/challenge-306/pokgopun/go/ch-2.go b/challenge-306/pokgopun/go/ch-2.go
index fac02f55d4..dce30eb496 100644
--- a/challenge-306/pokgopun/go/ch-2.go
+++ b/challenge-306/pokgopun/go/ch-2.go
@@ -65,8 +65,10 @@ func (is ints) lstelm() int {
return 0
case 1:
return is[0]
+ case 2:
+ default:
+ slices.Sort(is)
}
- slices.Sort(is)
d := is[l-2] - is[l-1]
if d == 0 {
is = is[:l-2]
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]