Last active
December 27, 2015 03:39
-
-
Save HollyGurza/7261085 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
walls = [2,3,4,0,1,3,1,5,4,3,4,0,1,2,0,1,0,2,0,4] | |
lmax=0; | |
total=0; | |
copen=0; | |
buff=0; | |
print "\n-----------BEGIN ALG-----------\n" | |
if walls[0]>walls[1]: | |
lmax=walls[0]; | |
copen=1; | |
for i in range(1, len(walls)): | |
if walls[i]<walls[i-1]: | |
copen=1; | |
buff=buff+(lmax-walls[i]); | |
else: | |
if walls[i]<lmax: | |
buff=buff+(lmax-walls[i]); | |
buff=buff-(copen*(walls[i]-walls[i-1])); | |
total=total+(copen*(walls[i]-walls[i-1])); | |
copen=copen+1; | |
else: | |
total=total+buff; | |
buff=0; | |
copen=1; | |
lmax=walls[i]; | |
print "step "+str(i)+": total = " +str(total) + " buff = " +str(buff); | |
print "\nTOTAL = "+str(total); | |
print "\n-----------END ALG-----------\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another broken algorithm that depends on order.