diff --git a/README.md b/README.md index e4ff0f8..2efbb04 100644 --- a/README.md +++ b/README.md @@ -85,3 +85,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM ### en-route-salute * Completed in: 7 mins, 15 secs. + +### power-hungry +* Completed in: 16 mins, 49 secs. diff --git a/extra/power-hungry/solution.py b/extra/power-hungry/solution.py index f7f04e2..247d0bc 100644 --- a/extra/power-hungry/solution.py +++ b/extra/power-hungry/solution.py @@ -3,9 +3,12 @@ def solution(xs): return str(xs[0]) result = 1 max_negative = 0 + non_positive_only = True for power in xs: if power == 0: continue + if power > 0: + non_positive_only = False result *= power if power < 0: if max_negative == 0: @@ -14,6 +17,8 @@ def solution(xs): max_negative = max(max_negative, power) if max_negative < 0 and result < 0: result /= max_negative + if non_positive_only: + result = 0 return str(result) tests = [