Skip to content

Instantly share code, notes, and snippets.

@kspaans
Created September 5, 2011 14:13
Show Gist options
  • Save kspaans/1195084 to your computer and use it in GitHub Desktop.
Save kspaans/1195084 to your computer and use it in GitHub Desktop.
idiotic reverse of words in a list
while exists words:
if first word == second word:
exit()
i := start of first word
j := start of last word
if length of first word != length of last word:
MAGIC_SPECIAL_CASE()
len := length of first word
for len: swap(str[i++], str[j--])
bounds are now second word and second last word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment