/* private void Probando(int minNumber, int maxNumber, int maxNumerator, int maxDenominator, bool allReducible)
        {
            int randomIndex;
            int randomNumerator;
            int randomDenominator;
            List<int> indexes;
            indexes = new List<int> { 0, 1, 2, 3, 4, 5 };
            for (int i = 0; i < 6; i++)
            {
                numbersToDrag.Add(new numberManagement(-1, -1));
            }

            for (int i = 0; i < squareNumbersQuantity[0]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];
                do
                {
                    randomDenominator = (int)UnityEngine.Random.Range(2, maxDenominator);
                    randomNumerator = (int)UnityEngine.Random.Range(1, maxNumerator);
                    numbersToDrag[randomIndex] = new numberManagement(randomNumerator, randomDenominator);
                } while (numbersToDrag[randomIndex].GetFloat() >= ((numberLimits[0] + numberLimits[1]) / 2)
                                    || numbersToDrag[randomIndex].GetFloat() < minNumber
                                    || NumberRepeted(numbersToDrag[randomIndex].GetFloat())
                                    || Condition(numbersToDrag[randomIndex], !allReducible));
                if (!allReducible) { numbersToDrag[randomIndex].SymplifyFraction(); }
                numbersInOrder.Add(numbersToDrag[randomIndex].GetFloat());
                indexes.Remove(randomIndex);
            }
            for (int i = 0; i < squareNumbersQuantity[1]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];
                do
                {
                    randomDenominator = (int)UnityEngine.Random.Range(2, maxDenominator);
                    randomNumerator = (int)UnityEngine.Random.Range(1, maxNumerator);
                    numbersToDrag[randomIndex] = new numberManagement(randomNumerator, randomDenominator);
                } while (numbersToDrag[randomIndex].GetFloat() >= ((numberLimits[1] + numberLimits[2]) / 2)
                                   || numbersToDrag[randomIndex].GetFloat() <= (numberLimits[0] + numberLimits[1]) / 2
                                   || NumberRepeted(numbersToDrag[randomIndex].GetFloat())
                                   || Condition(numbersToDrag[randomIndex], !allReducible));
                if (!allReducible) { numbersToDrag[randomIndex].SymplifyFraction(); }
                numbersInOrder.Add(numbersToDrag[randomIndex].GetFloat());
                indexes.Remove(randomIndex);
            }
            for (int i = 0; i < squareNumbersQuantity[2]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];

                do
                {
                    randomDenominator = (int)UnityEngine.Random.Range(2, maxDenominator);
                    randomNumerator = (int)UnityEngine.Random.Range(1, maxNumerator);
                    numbersToDrag[randomIndex] = new numberManagement(randomNumerator, randomDenominator);
                } while (numbersToDrag[randomIndex].GetFloat() >= ((numberLimits[2] + numberLimits[3]) / 2)
                               || numbersToDrag[randomIndex].GetFloat() <= (numberLimits[1] + numberLimits[2]) / 2
                               || NumberRepeted(numbersToDrag[randomIndex].GetFloat())
                               || Condition(numbersToDrag[randomIndex], !allReducible));

                if (!allReducible) { numbersToDrag[randomIndex].SymplifyFraction(); }
                numbersInOrder.Add((float)randomNumerator / (float)randomDenominator);
                indexes.Remove(randomIndex);
            }
            for (int i = 0; i < squareNumbersQuantity[3]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];

                do
                {
                    randomDenominator = (int)UnityEngine.Random.Range(2, maxDenominator);
                    randomNumerator = (int)UnityEngine.Random.Range(1, maxNumerator);
                    numbersToDrag[randomIndex] = new numberManagement(randomNumerator, randomDenominator);
                } while (numbersToDrag[randomIndex].GetFloat() > maxNumber
                               || numbersToDrag[randomIndex].GetFloat() <= (numberLimits[2] + numberLimits[3]) / 2
                               || NumberRepeted(numbersToDrag[randomIndex].GetFloat())
                               || Condition(numbersToDrag[randomIndex], !allReducible));

                if (!allReducible) { numbersToDrag[randomIndex].SymplifyFraction(); }
                numbersInOrder.Add(numbersToDrag[randomIndex].GetFloat());
                indexes.Remove(randomIndex);
            }

            SetCurrentAnswer();
        }*/
        private void SelectFractionForSquare(int squareIndex, float minNumber, float maxNumber, int maxNumerator, int maxDenominator, bool allReducible)
        {
            int randomDenominator;
            int randomNumerator;
            int randomIndex;
            for (int i = 0; i < squareNumbersQuantity[squareIndex]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];
                do
                {
                    randomDenominator = (int)UnityEngine.Random.Range(2, maxDenominator);
                    randomNumerator = (int)UnityEngine.Random.Range(1, maxNumerator);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumerator, randomDenominator);
                } while (numbersToDrag[randomIndex].GetFloat() >= maxNumber
                                    || numbersToDrag[randomIndex].GetFloat() <= minNumber
                                    || NumberRepeted(numbersToDrag[randomIndex].GetFloat())
                                    || Condition(numbersToDrag[randomIndex], !allReducible));
                if (!allReducible) { numbersToDrag[randomIndex].SymplifyFraction(); }
                else if (!(numbersToDrag[randomIndex].GetNumerator() % numbersToDrag[randomIndex].GetDenominator() == 0)) {
                    do
                    {
                        numbersToDrag[randomIndex].AmplifyFraction(2, 4);
                    } while (numbersToDrag[randomIndex].GetDenominator() > MAX_DENOMINATOR);
                }
                numbersInOrder.Add(numbersToDrag[randomIndex].GetFloat());
                indexes.Remove(randomIndex);
            }
        }
        private void SelectNumbersToDrag(int minValue, int maxValue)
        {
            int randomIndex;
            int randomNumber;
            string randomNumberFloat;
            List<int> indexes;
            indexes = new List<int> { 0, 1, 2, 3, 4, 5};
            for (int i = 0; i < 6; i++)
            {
                numbersToDrag.Add(new NumberManagement(-1));
            }
            for (int i = 0; i < squareNumbersQuantity[0]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];

                if (currentId == 22)
                {
                    randomNumber = RandomNumberInt(minValue, (int) (numberLimits[0] + numberLimits[1]) / 2,
                        -1, (int)(numberLimits[0] + numberLimits[1]) / 2);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumber);
                    numbersInOrder.Add(randomNumber);
                }
                else
                {
                    randomNumberFloat = RandomNumberFloat(minValue, ((numberLimits[0] + numberLimits[1]) / 2) - 0.001f,
                        -1, (numberLimits[0] + numberLimits[1]) / 2);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumberFloat);
                    numbersInOrder.Add(Convert.ToSingle(randomNumberFloat));
                }

                indexes.Remove(randomIndex);
            }
            for (int i = 0; i < squareNumbersQuantity[1]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];

                if (currentId == 22)
                {
                    randomNumber = RandomNumberInt( (int)((numberLimits[0] + numberLimits[1]) / 2) + 1, (int)(numberLimits[1] + numberLimits[2]) / 2,
                       (int)(numberLimits[0] + numberLimits[1]) / 2, (int)(numberLimits[1] + numberLimits[2]) / 2);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumber);
                    numbersInOrder.Add(randomNumber);
                }
                else
                {
                    randomNumberFloat = RandomNumberFloat((numberLimits[0] + numberLimits[1]) / 2 + 0.001f, (numberLimits[1] + numberLimits[2]) / 2 - 0.001f,
                    (numberLimits[0] + numberLimits[1]) / 2, (numberLimits[1] + numberLimits[2]) / 2);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumberFloat);
                    numbersInOrder.Add(Convert.ToSingle(randomNumberFloat));
                }

                indexes.Remove(randomIndex);
            }
            for (int i = 0; i < squareNumbersQuantity[2]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];

                if (currentId == 22)
                {
                    randomNumber = RandomNumberInt((int)(numberLimits[1] + numberLimits[2]) / 2 + 1, (int)(numberLimits[2] + numberLimits[3]) / 2,
                        (int)(numberLimits[1] + numberLimits[2]) / 2, (int)(numberLimits[2] + numberLimits[3]) / 2);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumber);
                    numbersInOrder.Add(randomNumber);
                }
                else
                {
                    randomNumberFloat = RandomNumberFloat(((numberLimits[1] + numberLimits[2]) / 2) + 0.001f, ((numberLimits[2] + numberLimits[3]) / 2) - 0.001f,
                        (numberLimits[1] + numberLimits[2]) / 2, (numberLimits[2] + numberLimits[3]) / 2);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumberFloat);
                    numbersInOrder.Add(Convert.ToSingle(randomNumberFloat));
                }

                indexes.Remove(randomIndex);
            }
            for (int i = 0; i < squareNumbersQuantity[3]; i++)
            {
                randomIndex = indexes[UnityEngine.Random.Range(0, indexes.Count)];

                if (currentId == 22)
                {
                    randomNumber = RandomNumberInt((int)(numberLimits[2] + numberLimits[3]) / 2 + 1, maxValue,
                        (int)(numberLimits[2] + numberLimits[3]) / 2, -1);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumber);
                    numbersInOrder.Add(randomNumber);
                }
                else
                {
                    randomNumberFloat = RandomNumberFloat((numberLimits[2] + numberLimits[3]) / 2 + 0.001f, maxValue - 0.001f,
                        (numberLimits[2] + numberLimits[3]) / 2, -1);
                    numbersToDrag[randomIndex] = new NumberManagement(randomNumberFloat);
                    numbersInOrder.Add(Convert.ToSingle(randomNumberFloat));
                }

                indexes.Remove(randomIndex);
            }

            SetCurrentAnswer();
        }
        private bool Condition(NumberManagement number, bool notReducible)
        {
            if (notReducible)
            {
                return number.GetNumerator() % number.GetDenominator() == 0;
            }
            int gcd_ab = MathStuff.GCD(number.GetNumerator(), number.GetDenominator());

            return (number.GetDenominator() / gcd_ab) * 2 > MAX_DENOMINATOR;
        }