Last active
November 28, 2016 21:51
-
-
Save urigoren/154da2bad95068e6dedaf3d9e511c3d6 to your computer and use it in GitHub Desktop.
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
from itertools import combinations | |
from functools import reduce | |
from pprint import pprint as pr | |
def all_arrangements(k): | |
m=k*(k+1)/2 | |
m_bits_on=set([tuple(reduce(lambda x,y:x[:y]+[1]+x[y+1:],c,[0]*(2*m+1))) for c in combinations(range(2*m+1),m)]) | |
return set([tuple(sorted(filter(lambda i:i>0,reduce(lambda x,y: x+[y] if y==0 else x[:-1]+[x[-1]+1,],p,[0])))) for p in m_bits_on]) | |
def move(t,n=1): | |
if n>1: | |
return move(move(t),n-1) | |
return tuple(sorted([x-1 for x in t if x>1]+[len(t)])) | |
def verify(f,a): | |
arrangements=sorted(map(lambda x: (f(x),f(x)-f(move(x)),x),a)) | |
pr(arrangements) | |
return all([v[1]<0 for v in arrangements]) or all([v[1]>0 for v in arrangements]) | |
if __name__=='__main__': | |
a = all_arrangements(3) | |
#f is proportional to the potential energy of the young diagram rotated by 45 degrees | |
#see: https://arxiv.org/pdf/1503.00885.pdf | |
f = lambda x: sum([(len(x)-i)*t+(t+1)*t/2.0 for i,t in enumerate(x)]) | |
verify(f,a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment