Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
Created March 4, 2014 07:53
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 tangentstorm/9342041 to your computer and use it in GitHub Desktop.
Save tangentstorm/9342041 to your computer and use it in GitHub Desktop.
# this is just the third step
input = [ 2, 8, 3, 5 ] # an array of unique items
n = len(input)
# (...)
order = [ 3, 0, 2, 1 ] # first two steps created this
output = [ 0 ] * n
for i in range(n):
output[order[i]] = input[i]
assert output == [8, 5, 3, 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment