In [1]:
n = 50;
print(str(n) + " squares.\n")
pi = SymmetricGroup(n).random_element();
pi_list = [pi(i) for i in range(1, n + 1)];

T  = RSK(pi_list)[0];

print("The permutation pi in cycle notation:")
print(pi);

print("\nThe permutation pi in one-line notation:")
print(pi_list)

print("\nThe insertion tableau T of pi:")
for row in T:
    print(list(row));

print("\nThe Young diagram for the shape of T:");

for part in T.shape():
    print("■ " * part);

print("\nThis Young diagram fits in a " + str(len(T[0])) + "x" + str(len(T)) + " rectangle.")
50 squares.

The permutation pi in cycle notation:
(1,13,21,26,3,9,42,12,5,24,23,45,31,40,50,30,46,37,22,7,49,15,44,47,10,19,41,39,11,27,35,28,20,38,6)(2,33,32,16,8)(4,17,34,18,29,43,14)(25,36,48)

The permutation pi in one-line notation:
[13, 33, 9, 17, 24, 1, 49, 2, 42, 19, 27, 5, 21, 4, 44, 8, 34, 29, 41, 38, 26, 7, 45, 23, 36, 3, 35, 20, 43, 46, 40, 16, 32, 18, 28, 48, 22, 6, 11, 50, 39, 12, 14, 47, 31, 37, 10, 25, 15, 30]

The insertion tableau T of pi:
[1, 2, 3, 6, 10, 12, 14, 15, 30, 50]
[4, 7, 11, 18, 22, 25, 31, 37, 47]
[5, 8, 16, 20, 23, 28, 46]
[9, 17, 19, 29, 32, 39, 48]
[13, 21, 26, 35, 40]
[24, 34, 36, 43]
[27, 38, 45]
[33, 44]
[41]
[42]
[49]

The Young diagram for the shape of T:
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ 
■ ■ ■ ■ ■ ■ ■ ■ ■ 
■ ■ ■ ■ ■ ■ ■ 
■ ■ ■ ■ ■ ■ ■ 
■ ■ ■ ■ ■ 
■ ■ ■ ■ 
■ ■ ■ 
■ ■ 
■ 
■ 
■ 

This Young diagram fits in a 10x11 rectangle.