Skip to content

Instantly share code, notes, and snippets.

@canassa
Created April 24, 2017 18:53
Show Gist options
  • Save canassa/8b36ec26e54f0562ad6deeacf08dccfd to your computer and use it in GitHub Desktop.
Save canassa/8b36ec26e54f0562ad6deeacf08dccfd to your computer and use it in GitHub Desktop.
maxPart
import sys
import time
from array import array
A = array('d', range(3000))
n = len(A)
max_sum = -sys.maxsize
von = bis = 0
add = 0
start_time = time.time() * 1000
for i in range(n):
for j in range(i, n):
summe = sum(A[i:j])
if summe > max_sum:
max_sum = summe
von = i
bis = j
time_taken = (time.time() * 1000) - start_time
print(time_taken)
print(max_sum, von, bis)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment