finish extra/gearing-up-for-destruction #22
@ -3,7 +3,7 @@ def solution(pegs):
|
||||
|
||||
if len(pegs) % 2 == 0:
|
||||
s = 2 * odd - 2 * even - pegs[-1] + pegs[0]
|
||||
if s <= 0:
|
||||
if 2*s < 3:
|
||||
return [-1, -1]
|
||||
if s % 3 == 0:
|
||||
return [2*s/3, 1]
|
||||
@ -11,7 +11,7 @@ def solution(pegs):
|
||||
return [2*s, 3]
|
||||
else:
|
||||
s = 2 * odd - 2 * even + pegs[-1] + pegs[0]
|
||||
if s <= 0:
|
||||
if 2*s < 1:
|
||||
return [-1, -1]
|
||||
return [2*s, 1]
|
||||
|
||||
@ -28,6 +28,8 @@ def sum_odd_even(pegs):
|
||||
tests = [
|
||||
([4, 30, 50], [12, 1]),
|
||||
([4, 17, 50], [-1, -1]),
|
||||
([1, 2], [-1, -1]),
|
||||
([1, 2, 3], [-1, -1]),
|
||||
]
|
||||
|
||||
for i, o in tests:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user