Created
April 18, 2013 03:20
-
-
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…
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
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