def assemble(L,n):
    print("newloop : " + str(n))
    sol=[]
    for i in range(0,len(L)):
         print("i="+str(i))
         a=dimChecker(L[i])
         print(a)
         if a>n:
             
             return []
         if a==n:
           return [L[i]]
         else:
             print("here")
             temp=assemble(L,n-a)

             print("temp=")
             print(temp)
             if len(temp)>=1:
                 
                 return L[i]+temp
             else :
                 return []










#In G2C3
print("In G2")
a=expand("[(2,0)/(0,2)/(1,3)/(0,2)^9/(0,2)^5/(1,1)^9/(1,1)^5/(0,0)^9/(0,0)^9/(0,0)^3]")
print(checker(a,basisA12,orderList2))
print(dimChecker(a))
basisA12.append(a)

#InC3
print("in C3")
b=expand("[(6,0)/(2,0)/(3,1)/(4,0)^4/(0,0)^4/(3,1)^4/(4,0)^3/(3,1)^3/(0,2)/(0,0)^3/(0,0)^8/(0,0)^6]")


c=expand("[(2,0)/(4,2)/(0,2)/(4,0)^4/(2,2)^4/(4,0)^3/(2,2)^3/(0,0)^3/(0,0)^8/(0,0)^3]")


d=expand("[(2,0)^3/(0,2)/(1,1)^2/(2,0)^4/(1,1)^8/(2,0)^3/(1,1)^6/(0,0)^3/(0,0)^9/(0,0)^9/(0,0)^6/(0,0)^9]")


e=expand("[(2,0)/(0,2)/(1,1)^4/(1,0)^8/(0,1)^8/(1,1)^4/(1,0)^8/(0,0)^8/(0,0)^8/(0,1)^8/(0,0)^3/(0,0)^9/(0,0)^3]")
        if test[i][0]==1:
            x=(test[i][1],)
            for j in range(2,len(test[i])):
                x=x+(test[i][j],)
            soltest.append(x)
    return(soltest)

###############################################################
###############################################################
###########A18
###############################################################
###############################################################

a=expand("[(2,0,0,0,0,0,0,0)/(0,2,0,0,0,0,0,0)/(0,0,2,0,0,0,0,0)/(0,0,0,2,0,0,0,0)/(0,0,0,0,2,0,0,0)/(0,0,0,0,0,2,0,0)/(0,0,0,0,0,0,2,0)/(0,0,0,0,0,0,0,2)/(1,1,1,1,0,0,0,0)/(1,1,0,0,1,1,0,0)/(1,1,0,0,0,0,1,1)/(1,0,1,0,1,0,0,1)/(1,0,1,0,0,1,1,0)/(1,0,0,1,1,0,1,0)/(1,0,0,1,0,1,0,1)/(0,0,1,1,1,1,0,0)/(0,0,1,1,0,0,1,1)/(0,0,0,0,1,1,1,1)/(0,1,1,0,1,0,0,1)/(0,1,1,0,0,1,1,0)/(0,1,0,1,1,0,1,0)/(0,1,0,1,0,1,0,1)]")
print("A18")
print(dimChecker(a))
print(latex(a))
basisA18=[[0]]
basisA18.append(a)

###############################################################
###############################################################
###########A17
###############################################################
###############################################################

a=[0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0]
orderList = order(7)
basisA17=[[0]]
#We make the basis from basis of A18
a[0]=diagA1(basisA18[1],1,2)
  sol=1
  for i in range(0,len(x)):
    sol = sol*(x[i]+1)
  return(sol)

def isZero(sol):
  return reduce(mul, (reduce(add, x, 0) for x in zip(*sol)), 1) == 0
L=[]
d=12
#List of all possible weights
for i in range(0,d-3):
    if i%2==0:
        L.append([(i,0,0)])
    else :
        temp=[(i,0,0),(i,0,0)]
        tempdim=dimChecker(temp)
        if tempdim<=d-4:
                L.append(temp)

o=order(3)
for i in range(0,len(L)):
    for j in range(0,len(o)): 
        temp=perm(o[j],L[i])
        if temp not in L:
            L.append(temp)
        
Ladd = [[(1,1,0)],[(2,2,0)],[(1,3,0)],[(1,1,2)]]
for i in range(0,len(Ladd)):
    for j in range(0,len(o)): 
        temp=perm(o[j],Ladd[i])
        if temp not in Ladd:


orderList3=order(3)
basisA13=[[0]]
basisA13Lambda1=[[0]]

for i in range(1,38):
    print("case i")
    LE8[i]=[]
    LE8[i]=concat([(1,1)],lambda1[i])
    LE8[i]=LE8[i]+concat([(1,0)],lambda4[i])
    LE8[i]=LE8[i]+[(2,0,0),(0,2,0)]
    LE8[i]=LE8[i]+concat([(0,0)],lambda2[i])
    LE8[i]=LE8[i]+concat([(0,1)],lambda5[i])
    if dimChecker(LE8[i])!=248:
        print("LE8 does not have dim 248 at i=")
        print(i)
        
    temp=checker(LE8[i],basisA13,orderList3)
    print(temp)
    if temp==-1:
        print("New element, added to basis")
        basisA13.append(LE8[i])
        basisA13Lambda1.append(lambda1[i])
    else:
        print("conjugate")



t=diagA1(basisA18[1],2,7)
t2=removeA1(t,7)
#print(t2[1])
#print(checker(t2,basis2,orderList6))
basis2.append(t2)





#In A1B4 in A1F4

temp=expand("[(1,1,1,0,1,0)/(1,1,1,0,0,1)/(1,1,0,1,1,0)/(1,1,0,1,0,1)/(1,1,1,1,0,0)/(1,1,0,0,1,1)/(1,1,0,0,0,0)^2/(1,3,0,0,0,0)/(0,2,1,1,0,0)/(0,2,0,0,1,1)/(0,2,0,0,0,0) /(0,2,1,0,1,0)/(0,2,1,0,0,1)/(0,2,0,1,1,0)/(0,2,0,1,0,1)/(0,2,0,0,0,0)^2/(0,0,2,0,0,0)/(0,0,0,2,0,0)/(0,0,0,0,2,0)/(0,0,0,0,0,2)/(0,0,1,1,1,1)/(0,0,1,1,0,0)/(0,0,0,0,1,1)/ (0,0,1,0,1,0)/(0,0,1,0,0,1)/(0,0,0,1,1,0)/(0,0,0,1,0,1)/(2,0,0,0,0,0)]")
print("In A1B4 in A1F4")
print(dimChecker(temp))
print(checker(temp,basis2,orderList6))



# In G2C3
print("in G2C3")

temp2=expand("[ (1,0,2,1,0,0)/(1,1,1,1,0,0)/(1,0,2,0,1,0)/(1,1,1,0,1,0)/(1,0,2,0,0,1)/(1,1,1,0,0,1)/(1,0,0,1,1,1)/(1,0,0,1,0,0)/(1,0,0,0,1,0)/(1,0,0,0,0,1)/ (0,0,2,0,0,0)^2/(0,1,1,0,0,0)^2/(0,0,2,1,1,0)/(0,1,1,1,1,0)/(0,0,2,1,0,1)/(0,1,1,1,0,1)/(0,0,2,0,1,1)/(0,1,1,0,1,1)/(0,2,0,0,0,0)/(0,0,2,0,0,0)/ (0,1,3,0,0,0)/(0,0,0,2,0,0)/(0,0,0,0,2,0)/(0,0,0,0,0,2)/(0,0,0,1,1,0)/(0,0,0,1,0,1)/ (0,0,0,0,1,1)/(2,0,0,0,0,0)]")
print(dimChecker(temp2))
print(checker(temp2,basis2,orderList6))






print("A_1^3 in D5")
lam=[0]
lam.append(expand("[(1,1,0)/(0,1,1)/(0,0,0)^2]"))
lam.append(expand("[(1,1,0)/(0,0,1)^2/(0,0,0)^2]"))
lam.append(expand("[(1,1,0)/(0,0,2)/(0,0,0)^3]"))
lam.append(expand("[(1,1,0)/(0,0,2)^2]"))
lam.append(expand("[(1,1,0)/(2,0,0)/(0,0,2)]"))
lam.append(expand("[(1,1,0)/(0,0,4)/(0,0,0)]"))
lam.append(expand("[(1,0,0)^2/(0,2,0)/(0,0,2)]"))
lam.append(expand("[(2,0,0)/(0,2,0)/(0,0,2)/(0,0,0)]"))
print(len(lam))
for i in range(1,len(lam)):
    print(dimChecker(lam[i]))




basisA13=[0]


basisA13.append(expand("[(1,4,1)/(1,2,1)/(1,0,3)/(2,0,0)/(0,4,2)/(0,4,0)/ (0,2,2)/(0,2,0)/(0,0,2)]"))
                       
basisA13.append(expand("[(1,2,2)^2/(1,0,0)^2/(2,0,0)/(0,4,0)/(0,0,4)/(0,2,0)/(0,0,2)/(0,2,2)^2/ (0,0,0)]"))

basisA13.append(expand("[(1,2,1)^2/(1,2,0)^2/(1,0,0)^2/(2,0,0)/(0,4,0)/(0,2,1)^2/(0,2,0)^3/(0,0,2)/(0,0,1)^2/(0,0,0)^2]"))

basisA13.append(expand("[(1,1,1)^2/(1,3,0)/(1,1,0)/(1,1,2)/(2,0,0)/(0,2,2)/ (0,2,0)^2/(0,0,2)/(0,2,1)^2/(0,0,1)^2/(0,0,0)]"))