solution to sportsball

This commit is contained in:
Stephen McQuay 2012-09-08 12:35:38 -06:00
parent eeacab67d4
commit e97f4e31b8
2 changed files with 24 additions and 0 deletions

21
sportsball/sportsball.py Normal file
View File

@ -0,0 +1,21 @@
import itertools
import sys
def run(nums):
best = 0
for i in xrange(len(nums)):
if nums[i] % 2 == 1:
cur_best = nums[i]
if cur_best > best: best = cur_best
for j in xrange(i + 1, len(nums)):
if nums[j] % 2 == 0:
break
cur_best += nums[j]
if cur_best > best:
best = cur_best
print best
for line in sys.stdin:
nums = [int(i) for i in line.strip().split()]
run(nums)

3
sportsball/stdin1.txt Normal file
View File

@ -0,0 +1,3 @@
4 8 15 16 -23 42
41 4 -36 35 47 8 -21 8
1 43 -31 17 23 -45 -42 32 -2 -28