<s> """<STR_LIT>""" <EOL> Infinity = <NUM_LIT> <EOL> def max_sum ( a ) : <EOL> """<STR_LIT>""" <EOL> max_sum , max_start_index , max_end_index = - Infinity , <NUM_LIT:0> , <NUM_LIT:0> <EOL> current_max_sum = <NUM_LIT:0> <EOL> current_start_index = <NUM_LIT:0> <EOL> for current_end_index , x in enumerate ( a ) : <EOL> current_max_sum += x <EOL> if current_max_sum > max_sum : <EOL> max_sum , max_start_index , max_end_index = current_max_sum , current_start_index , current_end_index <EOL> if current_max_sum < <NUM_LIT:0> : <EOL> current_max_sum = <NUM_LIT:0> <EOL> current_start_index = current_end_index + <NUM_LIT:1> <EOL> return max_sum , max_start_index , max_end_index <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import doctest <EOL> doctest . testmod ( ) <EOL> import numpy as np <EOL> A = np . random . random_integers ( - <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> print "<STR_LIT>" % list ( A ) <EOL> print max_sum ( A ) </s>
