Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Created May 10, 2011 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmoud/964110 to your computer and use it in GitHub Desktop.
Save mahmoud/964110 to your computer and use it in GitHub Desktop.
this is terrible, but it'll probably work
# 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.
Copy link

ghost commented May 10, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment