Skip to content

Instantly share code, notes, and snippets.

@calebegg
Created April 18, 2013 03:20
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 calebegg/5409802 to your computer and use it in GitHub Desktop.
Save calebegg/5409802 to your computer and use it in GitHub Desktop.
When offering an ordering of a list, there are two ways to interpret it: 1. This ordering supplies the location to which each item should be moved. 2. This ordering supplies the location from which each item should be pulled. So, for instance, if the original list is [a, b, c] and the ordering you wish to apply is [2, 3, 1], by method (1) you ge…
ln = 9
yesses = 0
nos = 0
for p in permutations(range(ln)):
ys = [0] * ln
for i in range(ln):
ys[p[i]] = i
if ys == p:
yesses += 1
else:
nos += 1
print yesses / (yesses + nos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment