finish extra/power-hungry
Submitting solution... Submission: SUCCESSFUL. Completed in: 16 mins, 49 secs.
This commit is contained in:
parent
e5833ae10c
commit
53116f6ff5
@ -85,3 +85,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM
|
|||||||
|
|
||||||
### en-route-salute
|
### en-route-salute
|
||||||
* Completed in: 7 mins, 15 secs.
|
* 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])
|
return str(xs[0])
|
||||||
result = 1
|
result = 1
|
||||||
max_negative = 0
|
max_negative = 0
|
||||||
|
non_positive_only = True
|
||||||
for power in xs:
|
for power in xs:
|
||||||
if power == 0:
|
if power == 0:
|
||||||
continue
|
continue
|
||||||
|
if power > 0:
|
||||||
|
non_positive_only = False
|
||||||
result *= power
|
result *= power
|
||||||
if power < 0:
|
if power < 0:
|
||||||
if max_negative == 0:
|
if max_negative == 0:
|
||||||
@ -14,6 +17,8 @@ def solution(xs):
|
|||||||
max_negative = max(max_negative, power)
|
max_negative = max(max_negative, power)
|
||||||
if max_negative < 0 and result < 0:
|
if max_negative < 0 and result < 0:
|
||||||
result /= max_negative
|
result /= max_negative
|
||||||
|
if non_positive_only:
|
||||||
|
result = 0
|
||||||
return str(result)
|
return str(result)
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user