Browse Source

solution to sportsball

master
Stephen McQuay 8 years ago
parent
commit
e97f4e31b8
2 changed files with 24 additions and 0 deletions
  1. +21
    -0
      sportsball/sportsball.py
  2. +3
    -0
      sportsball/stdin1.txt

+ 21
- 0
sportsball/sportsball.py 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
- 0
sportsball/stdin1.txt 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

Loading…
Cancel
Save