@@ -0,0 +1,1225 @@
+import java.util.*; %0Aclass CoxeterElement %7B%0A    private int%5B%5D expression;%0A    private int rank = 0;%0A    private int length;%0A%0A    public CoxeterElement(int%5B%5D input, int rank) %7B%0A%09boolean validElement = true;%0A%09%0A%09// Check all generators are legal%0A%09for(int i = 0; i %3C input.length; i++) %7B%0A%09    if ((input%5Bi%5D %3E rank) %7C (input%5Bi%5D %3C 1)) %7B%0A%09%09validElement = false;%0A%09    %7D%0A%09%7D%0A%09%0A%09if (validElement) %7B%0A%09    this.rank = rank;%0A%09    this.length = input.length;%0A%09    this.expression = new int%5Blength%5D;%0A%09    for(int i = 0; i %3C input.length; i++) %7B%0A%09%09expression%5Bi%5D = input%5Bi%5D;%0A%09    %7D%0A%09%7D%0A%09else %7B%0A%09    System.out.println(%22Invalid element%22);%0A%09%7D%0A    %7D%0A%0A    public Element toPermutation() %7B%0A%09int%5B%5D permutation = new int%5Brank%5D;%0A%09int temp;%0A%09int generator;%0A%09Element answer;%0A%0A%09for (int i = 0; i %3C rank; i++) %7B%0A%09    permutation%5Bi%5D = i + 1;%0A%09%7D%0A%09for (int i = 0; i %3C length; i++) %7B%0A%09    generator = expression%5Bi%5D;%0A%09    if (generator %3E 1) %7B%0A%09%09temp = permutation%5Bgenerator - 2%5D;%0A%09%09permutation%5Bgenerator - 2%5D = permutation%5Bgenerator - 1%5D;%0A%09%09permutation%5Bgenerator - 1%5D = temp;%0A%09    %7D%0A%09    else %7B%0A%09%09temp = permutation%5B0%5D;%0A%09%09permutation%5B0%5D = -1*permutation%5B1%5D;%0A%09%09permutation%5B1%5D = -1*temp;%0A%09    %7D%0A%09%7D%0A%09answer = new Element(permutation);%0A%09return answer;%0A    %7D%0A    %0A%7D%0A

Add class to deal with expressions in terms of generators