Created
May 10, 2011 08:36
-
-
Save mahmoud/964110 to your computer and use it in GitHub Desktop.
this is terrible, but it'll probably work
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
# actually not python, just pseudocode highlighted like python. | |
if( len(ints) < 2 ) # if the list is short, just exit | |
return | |
for (i=1; i < len(ints)-1; ++i): # for each of the list entries, from the second to the second to last | |
if ints[i] == ints[i-1] or ints[i] == ints[i+1]: # if the entry to the left or entry to the right is equal to the current one | |
ints[i] = ints[i] + 1 # add one to the current one | |
i = i - 1 # set the cursor back one, because continuing/looping again will cause it to move forward | |
continue # repeat the loop to make sure our +1 change was ok. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
actually not python, just pseudocode highlighted like python.
if( len(ints) < 1 )
return
for (i=1; i < len(ints)-1; ++i):
if ints[i] == ints[i-1] or ints[i] == ints[i+1]:
ints[i] = ints[i-1] + inst[i+1]
continue