finish extra/power-hungry #19
@ -85,3 +85,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM
|
||||
|
||||
### en-route-salute
|
||||
* Completed in: 7 mins, 15 secs.
|
||||
|
||||
### power-hungry
|
||||
* Completed in: 16 mins, 49 secs.
|
||||
|
||||
@ -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 = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user