Skip to content

Instantly share code, notes, and snippets.

@calebrob6
Last active December 25, 2015 00:09
Show Gist options
  • Save calebrob6/6885422 to your computer and use it in GitHub Desktop.
Save calebrob6/6885422 to your computer and use it in GitHub Desktop.
f=open("3774.txt","r")
try:
while True:
b=[tuple(f.readline().strip().split(",")+[0]) for i in range(int(f.readline().strip()))]
a=reduce(lambda a,b:(b[0],b[1],a[2]+((float(b[0])-float(a[0]))*((float(a[1])+float(b[1]))/2))),b)
print "%.2f to %.2f: %.4f" % (float(b[0][0]),float(a[0]),a[2])
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment