Exemplo n.º 1
0
 static public void WritePower(int[] permutation, int power)
 {
     int[][] cyclePermutation       = WithoutRepetition.PermutationToCycle(permutation);
     int[]   resultPermutation      = WithoutRepetition.PowerOfPermutation(permutation, power);
     int[][] resultCyclePermutation = WithoutRepetition.PermutationToCycle(resultPermutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Power of permutation:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer, "Power: " + power);
         WriteLine(writer);
         WriteLine(writer, "Result permutation");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, resultPermutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, resultCyclePermutation);
         WriteLine(writer);
     }
 }
Exemplo n.º 2
0
 static public void WriteReverse(int[] permutation)
 {
     int[]   reversePermutation      = WithoutRepetition.ReversePermutation(permutation);
     int[][] cycleReversePermutation = WithoutRepetition.PermutationToCycle(reversePermutation);
     int[][] cyclePermutation        = WithoutRepetition.PermutationToCycle(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Reverse permutation:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         WriteLine(writer, "Result:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, reversePermutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cycleReversePermutation);
         WriteLine(writer);
     }
 }
Exemplo n.º 3
0
 static public void WriteIsOneCycle(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "If permutation is one cycle:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         Write(writer, "Is one cycle? - ");
         if (WithoutRepetition.IsOneCycle(permutation))
         {
             Write(writer, "yes");
         }
         else
         {
             Write(writer, "no");
         }
         WriteLine(writer);
     }
 }
Exemplo n.º 4
0
 internal static bool isAnyComposition(int[][] permutations)
 {
     for (int i = 0; i < permutations.Length; i++)
     {
         for (int j = 0; j < permutations.Length; j++)
         {
             int[] composition = WithoutRepetition.CompositionOfPermutation(permutations[i], permutations[j]);
             bool  flag        = false;
             for (int k = 0; k < permutations.Length; k++)
             {
                 if (!flag)
                 {
                     if (ArrayFunctions.compareIntArrays(composition, permutations[k]))
                     {
                         flag = true;
                     }
                 }
             }
             if (!flag)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 5
0
 static public void WriteType(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     int[]   vectorType       = WithoutRepetition.TypeOfPermutation(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Type of permutation:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         Write(writer, "Type of permutation: [");
         string toWrite = "";
         for (int i = 1; i < vectorType.Length; i++)
         {
             if (vectorType[i] != 0)
             {
                 toWrite += i + "^" + vectorType[i] + " ";
             }
         }
         toWrite = toWrite.Remove(toWrite.Length - 1, 1);
         Write(writer, toWrite);
         Write(writer, "]");
         WriteLine(writer);
     }
 }
Exemplo n.º 6
0
        static public void IsGroupProve(int[][] permutations)
        {
            string prove = WithoutRepetition.PermutationGroupFacts(permutations);

            using (StreamWriter writer = new StreamWriter("log.txt", true))
            {
                WriteDate(writer);
                WriteLine(writer, prove);
            }
        }
Exemplo n.º 7
0
        static public void IsGroup(int[][] permutations)
        {
            bool isGroup = WithoutRepetition.IsPermutationGroup(permutations);

            using (StreamWriter writer = new StreamWriter("log.txt", true))
            {
                WriteDate(writer);
                WriteLine(writer, "Is permutations are a group?- " + isGroup);
            }
        }
Exemplo n.º 8
0
 static public void WriteGenerateRandom(int n)
 {
     int[] permutation = WithoutRepetition.GenerateRandomPermutation(n);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Random permutation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
     }
 }
Exemplo n.º 9
0
 static public void WritePermutationFromIndexALO(int number, int n) //ALO - anti lexicographical order
 {
     int[] permutation = WithoutRepetition.PermutationFromAntiLexOrderIndex(number, n);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Permutation from index in anti lexicographical order: ");
         WriteLine(writer);
         WriteLine(writer, "Index of permutation: " + number);
         WriteLine(writer, "Number of elements: " + n);
         WriteLine(writer);
         Write(writer, "Permutation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
     }
 }
Exemplo n.º 10
0
        public static string PowerOfPermutationString(string Expression)
        {
            int    index = Expression.IndexOf("^");
            int    power = 0;
            string temp  = Expression.Substring(index + 1);

            power = int.Parse(temp);
            string cyclePermutationString = Expression.Remove(index);

            int[]   permutation             = ParsePermutation(cyclePermutationString);
            int[]   resultPermutation       = WithoutRepetition.PowerOfPermutation(permutation, power);
            int[][] resultPermutationCycle  = WithoutRepetition.PermutationToCycle(resultPermutation);
            string  resultPermutationString = CycleToString(resultPermutationCycle);

            return(resultPermutationString);
        }
Exemplo n.º 11
0
        static public void GeneratePermutations(string number)
        {
            int numberInt = int.Parse(number);

            using (StreamWriter writer = new StreamWriter("log.txt", true))
            {
                WriteDate(writer);
                WriteLine(writer, "Generating permutations...");
                int[][] permutations = WithoutRepetition.AllPermutationsInLexOrder(numberInt);
                for (int i = 0; i < permutations.Length; i++)
                {
                    Write(writer, (i + 1) + ") ");
                    WriteVector(writer, permutations[i]);
                    WriteLine(writer);
                }
            }
        }
Exemplo n.º 12
0
 static public int[] ParsePermutation(string permutation)
 {
     int[] returnedPermutation = { 1, 2 };
     if (permutation[0] == '<')
     {
         returnedPermutation = ParseVector(permutation);
     }
     else if (permutation[0] == '(')
     {
         int[][] cyclePermutation = ParseCycle(permutation);
         returnedPermutation = WithoutRepetition.CycleToPermutation(cyclePermutation);
     }
     else
     {
         throw new Exception("Bad format of permutation.");
     }
     return(returnedPermutation);
 }
Exemplo n.º 13
0
 static public void WriteOrder(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Order of permutation:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         Write(writer, "Order of permutation: " + WithoutRepetition.OrderOfPermutation(permutation));
         WriteLine(writer);
     }
 }
Exemplo n.º 14
0
 static public void WriteCompositionOfNeighbouringTranposition2(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     int[][] transpositions   = WithoutRepetition.PermutationToNeighbouringTransposition2(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteCycle(writer, cyclePermutation);
         Write(writer, "=");
         for (int i = 0; i < transpositions.Length - 1; i++)
         {
             int[][] cycleTransposition = WithoutRepetition.PermutationToCycle(transpositions[i]);
             WriteTransposition(writer, cycleTransposition);
             Write(writer, "*");
         }
         int[][] cycleTranspositionLast = WithoutRepetition.PermutationToCycle(transpositions[transpositions.Length - 1]);
         WriteTransposition(writer, cycleTranspositionLast);
         WriteLine(writer); WriteLine(writer);
     }
 }
Exemplo n.º 15
0
 static public void WritePermutationWithOrder(int order, int length)
 {
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Generating permutations for order: " + order + " and length: " + length);
         WriteLine(writer);
         int[][] permutations = WithoutRepetition.AllPermutationsOfGivenOrder(order, length);
         int     counter      = 1;
         foreach (int[] permutation in permutations)
         {
             Write(writer, counter + ") ");
             counter++;
             WriteVector(writer, permutation);
             WriteLine(writer);
         }
         WriteLine(writer);
     }
 }
Exemplo n.º 16
0
 static public void WriteCountFixedPoints(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Count fixed points of permutation:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         Write(writer, "Number of fixed points " + WithoutRepetition.FixedPointsCount(permutation));
         WriteLine(writer);
     }
 }
Exemplo n.º 17
0
 static public void WriteCountInversions(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Count inversions of permutation:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         Write(writer, "Number of inversions " + HelpFunctions.inversionsCount(permutation));
         WriteLine(writer);
     }
 }
Exemplo n.º 18
0
 static public void WriteSign4(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Sign of permutation");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         Write(writer, "Value of sign: ");
         Write(writer, WithoutRepetition.SignOfPermutation4(permutation) + "");
         WriteLine(writer);
     }
 }
Exemplo n.º 19
0
        static public void WriteGenerateWithType(string type)
        {
            int[] vectorType = Parsing.ParseType(type);

            using (StreamWriter writer = new StreamWriter("log.txt", true))
            {
                WriteDate(writer);
                WriteLine(writer, "Generating permutations for type: " + type);
                WriteLine(writer);
                int[][] permutations = WithoutRepetition.AllPermutationsOfGivenType(vectorType);
                int     counter      = 1;
                foreach (int[] permutation in permutations)
                {
                    Write(writer, counter + ") ");
                    counter++;
                    WriteVector(writer, permutation);
                    WriteLine(writer);
                }
                WriteLine(writer);
            }
        }
Exemplo n.º 20
0
        static public void WritePermutationIndexALO(int[] permutation) // ALO- anti lexicographical order
        {
            int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
            long    index            = WithoutRepetition.PermutationIndexInAntiLexOrder(permutation);

            using (StreamWriter writer = new StreamWriter("log.txt", true))
            {
                WriteDate(writer);
                WriteLine(writer, "Permutation index in anti lexicographical order: ");
                WriteLine(writer);
                Write(writer, "One-line notation: ");
                WriteVector(writer, permutation);
                WriteLine(writer);
                Write(writer, "Canonical cycle notation: ");
                WriteCycle(writer, cyclePermutation);
                WriteLine(writer);
                WriteLine(writer);
                WriteLine(writer, "Index: " + index);
                WriteLine(writer);
            }
        }
Exemplo n.º 21
0
 static public void WriteInversionVector(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     int[]   inversionVector  = WithoutRepetition.InversionVector(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Iversion vector of permutation:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         Write(writer, "Inversion vector: ");
         WriteVector(writer, inversionVector);
         WriteLine(writer);
     }
 }
Exemplo n.º 22
0
 static public void WriteInversionCommand(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     int[][] listOfInversions = WithoutRepetition.ListOfInversions(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Writing inversions of permutation:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         WriteLine(writer, "Writing inversions");
         WriteLine(writer);
         WriteInversions(writer, listOfInversions);
         WriteLine(writer);
     }
 }
Exemplo n.º 23
0
 internal static bool isAnyReverse(int[][] permutations)
 {
     for (int i = 0; i < permutations.Length; i++)
     {
         bool flag = false;
         for (int j = 0; j < permutations.Length; j++)
         {
             if (!flag)
             {
                 int[] reverse = WithoutRepetition.ReversePermutation(permutations[j]);
                 if (ArrayFunctions.compareIntArrays(permutations[i], reverse))
                 {
                     flag = true;
                 }
             }
         }
         if (!flag)
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 24
0
 static public void WriteNotations(int[] permutation)
 {
     int[][] cyclePermutation = WithoutRepetition.PermutationToCycle(permutation);
     int[,] matrixPermutation = WithoutRepetition.PermutationToMatrix(permutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Permutation in different notations:");
         WriteLine(writer);
         Write(writer, "One-line notation: ");
         WriteVector(writer, permutation);
         WriteLine(writer);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, cyclePermutation);
         WriteLine(writer);
         WriteLine(writer);
         WriteLine(writer, "Matrix notation:");
         WriteLine(writer);
         WriteMatrix(writer, matrixPermutation);
         WriteLine(writer);
     }
 }
Exemplo n.º 25
0
 static public void WriteComposition(int[] leftPermutation, int[] rightPermutation)
 {
     int[]   resultPermutation      = WithoutRepetition.CompositionOfPermutation(leftPermutation, rightPermutation);
     int[][] resultPermutationCycle = WithoutRepetition.PermutationToCycle(resultPermutation);
     int[][] leftPermutationCycle   = WithoutRepetition.PermutationToCycle(leftPermutation);
     int[][] rightPermutationCycle  = WithoutRepetition.PermutationToCycle(rightPermutation);
     using (StreamWriter writer = new StreamWriter("log.txt", true))
     {
         WriteDate(writer);
         WriteLine(writer, "Composition permutations:");
         WriteLine(writer);
         WriteLine(writer, "Left Permutation:");
         Write(writer, "One-line notation: ");
         WriteVector(writer, leftPermutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, leftPermutationCycle);
         WriteLine(writer);
         WriteLine(writer);
         WriteLine(writer, "Right Permutation:");
         Write(writer, "One-line notation: ");
         WriteVector(writer, rightPermutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, rightPermutationCycle);
         WriteLine(writer);
         WriteLine(writer);
         WriteLine(writer, "Result Permutation:");
         Write(writer, "One-line notation: ");
         WriteVector(writer, resultPermutation);
         WriteLine(writer);
         Write(writer, "Canonical cycle notation: ");
         WriteCycle(writer, resultPermutationCycle);
         WriteLine(writer);
     }
 }
Exemplo n.º 26
0
        static string CalculateExpression(string Expression)
        {
            while (Expression.Contains("(("))
            {
                int indexFirst = Expression.IndexOf("(("), indexLast = 0;
                int counter = 2;
                for (int i = indexFirst + 2; i < Expression.Length; i++)
                {
                    if (Expression[i] == '(')
                    {
                        counter++;
                    }
                    else if (Expression[i] == ')')
                    {
                        counter--;
                        if (counter == 0)
                        {
                            indexLast = i;
                            break;
                        }
                    }
                }
                string temp = Expression.Substring(indexFirst + 1, (indexLast - 1) - (indexFirst + 1) + 1);

                string newExpression = CalculateExpression(temp);

                string tempExpression = "";
                if (indexFirst != 0)
                {
                    tempExpression += Expression.Substring(0, indexFirst);
                }
                tempExpression += newExpression;
                if (indexLast != (Expression.Length - 1))
                {
                    tempExpression += Expression.Substring(indexLast + 1, Expression.Length - 1 - (indexLast + 1) + 1);
                }
                Expression = tempExpression;
            }
            string[] expressions = Expression.Split('*');

            string returnedExpression = "";

            for (int i = 0; i < expressions.Length; i++)
            {
                if (expressions[i].Contains("^"))
                {
                    expressions[i] = PowerOfPermutationString(expressions[i]);
                }
            }
            if (expressions.Length > 1)
            {
                int[]   returnedPermutation;
                int[][] returnedPermutationCycle;
                int[]   permutation1 = ParsePermutation(expressions[0]);
                int[]   permutation2 = ParsePermutation(expressions[1]);
                returnedPermutation = WithoutRepetition.CompositionOfPermutation(permutation1, permutation2);
                for (int i = 2; i < expressions.Length; i++)
                {
                    int[] permutation = ParsePermutation(expressions[i]);
                    returnedPermutation = WithoutRepetition.CompositionOfPermutation(returnedPermutation, permutation);
                }
                returnedPermutationCycle = WithoutRepetition.PermutationToCycle(returnedPermutation);
                returnedExpression       = CycleToString(returnedPermutationCycle);
            }
            else
            {
                returnedExpression = expressions[0];
            }
            return(returnedExpression);
        }
Exemplo n.º 27
0
        public static string ParseExpression(string Expression)
        {
            string[]  expressions = Expression.Split('='); //podzielenie na strone prawą i lewą
            string    rightOfExpression = "", leftOfExpression = "";
            string    toReturn  = "";
            Exception exception = new Exception("Bad format of expression.");

            if (expressions.Length != 2)
            {
                throw exception;
            }
            bool flag = false; // flaga czy już zostało znalezione f w wyrażeniu

            for (int i = 0; i < expressions[0].Length; i++)
            {
                if (expressions[0][i] == 'f')
                {
                    if (flag)
                    {
                        throw exception;
                    }
                    else
                    {
                        leftOfExpression  = expressions[0];
                        rightOfExpression = expressions[1];
                        flag = true;
                    }
                }
            }
            for (int i = 0; i < expressions[1].Length; i++)
            {
                if (expressions[1][i] == 'f')
                {
                    if (flag)
                    {
                        throw exception;
                    }
                    else
                    {
                        leftOfExpression  = expressions[1];
                        rightOfExpression = expressions[0];
                        flag = true;
                    }
                }
            }
            if (!flag)
            {
                throw exception;
            }
            while (leftOfExpression.Contains("(") || leftOfExpression.Contains(")") || leftOfExpression.Contains("*"))
            {
                string[] divided = DivideExpression(leftOfExpression);
                if (divided.Length == 1)
                {
                    if (isToPower(divided[0]))
                    {
                        int      indexOfPower  = SearchIndexPower(divided[0]);
                        string   divideToPower = divided[0].Substring(1, indexOfPower - 2);
                        string[] toPower       = DivideExpression(divideToPower);
                        int      power         = int.Parse(divided[0].Substring(indexOfPower + 1)); //+1 bo indexOfPower to index '^'
                        for (int i = 0; i < toPower.Length; i++)
                        {
                            if (isToPower(toPower[i]))
                            {
                                int indexOfS = SearchIndexPower(toPower[i]);
                                int powerOfS = int.Parse(toPower[i].Substring(indexOfS + 1));
                                toPower[i] = toPower[i].Substring(0, indexOfS + 1) + (powerOfS * power);
                            }
                            else
                            {
                                toPower[i] = toPower[i] + "^" + power;
                            }
                        }
                        leftOfExpression = "";
                        for (int i = 0; i < toPower.Length; i++)
                        {
                            if (i == toPower.Length - 1)
                            {
                                leftOfExpression += toPower[i];
                            }
                            else
                            {
                                leftOfExpression += toPower[i] + "*";
                            }
                        }
                    }
                    else
                    {
                        leftOfExpression = divided[0].Substring(1, divided[0].Length - 2);
                    }
                }
                else
                {
                    int  indexOfF = 0;
                    bool flagF    = false;
                    for (int i = 0; i < divided.Length; i++)
                    {
                        if (divided[i].Contains("f"))
                        {
                            indexOfF = i;
                            flagF    = true;
                        }
                    }
                    if (!flagF)
                    {
                        throw exception;
                    }
                    string left = "", right = "";
                    for (int i = 0; i < indexOfF; i++)
                    {
                        if (i == indexOfF - 1)
                        {
                            left += "(" + divided[i] + ")^-1";
                        }
                        else
                        {
                            left += "(" + divided[i] + ")^-1" + "*";
                        }
                    }
                    for (int i = divided.Length - 1; i >= indexOfF + 1; i--)
                    {
                        if (i == indexOfF + 1)
                        {
                            right += "(" + divided[i] + ")^-1";
                        }
                        else
                        {
                            right += "(" + divided[i] + ")^-1" + "*";
                        }
                    }

                    if (left.Length > 0)
                    {
                        //left = "(" + left + ")^-1";
                        rightOfExpression = left + "*" + rightOfExpression;
                    }
                    if (right.Length > 0)
                    {
                        //right = "(" + right + ")^-1";
                        rightOfExpression = rightOfExpression + "*" + right;
                    }
                    leftOfExpression = divided[indexOfF];
                }
            }
            //Console.WriteLine("Right: " + rightOfExpression);
            rightOfExpression = CalculateExpression(rightOfExpression);

            if (leftOfExpression.Contains("^"))
            {
                int     i                 = leftOfExpression.IndexOf('^');
                string  toParse           = leftOfExpression.Substring(i + 1);
                int     root              = int.Parse(toParse);
                int[]   permutationToRoot = ParsePermutation(rightOfExpression);
                int[][] Cases             = WithoutRepetition.RootOfPermutation(permutationToRoot, root);
                if (Cases.Length == 0)
                {
                    toReturn += "There aren't any solutions.";
                }
                else
                {
                    int[][] permutationCycle = WithoutRepetition.PermutationToCycle(Cases[0]);
                    toReturn += "f=" + CycleToString(permutationCycle);
                    if (Cases.Length > 1)
                    {
                        for (int k = 1; k < Cases.Length; k++)
                        {
                            permutationCycle = WithoutRepetition.PermutationToCycle(Cases[k]);
                            toReturn        += "||f=" + CycleToString(permutationCycle);
                        }
                    }
                }

                /*
                 * int[][] permutationCycle = WithoutRepetition.PermutationToCycle(Cases);
                 * rightOfExpression = CycleToString(permutationCycle);*/
            }

            return(toReturn);
            //return "f=" + rightOfExpression;
        }