#computes character table of S_n, for small enough n
#note: correct up to n = 25

#parameters
print_representatives = False

#computes conjugacy number of conjugacy classes and cycle type
def f(n):
  big_list = []
  if n != 1:
    returned = f(n-1)
    for l in returned:
      temp = l
      temp.append(1)
      big_list.append(temp)
    if n/2 >= 2:
      j = 2
      while j <= n-2:
        returned = f(j) #we have fresh list of f(j)
        for l in returned:
          if l.count(1) == 0:
            k = 2
            pretotal = 0
            for p in l:
              pretotal = pretotal + p
            while k + pretotal < n:
              k = k + 1
            if k <= l[len(l) - 1]:
              l.append(k)
              big_list.append(l)
        
        j = j+1
  big_list.append([n])
  return big_list

#interface loop thingy
end = False
x = 0
while end == False:
	tmp = input("Compute the characer table of S_n, for n =")
	if tmp == "end":
		end = True
	else:
		x = int(tmp)
		if x <= 0:
		  print("please enter n > 0") #?
		else:
		  bloop = f(x)
		  print("The group S_n has %3u conjugacy classes." %len(bloop))
		  if print_representatives:
		    print("The representative for each class are lsited below:")
		    for m in bloop:
		      print("   ",m) #I lied, I still need to finish this properly