public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line      = file.ReadLine();
                var inputSize = line;

                var line2    = file.ReadLine();
                var inputStr = line2;
                TestInputs.Add(inputStr);

                var result = FirstNonRepChar(inputStr).ToString();
                if (System.String.IsNullOrEmpty(result))
                {
                    result = "-1";
                }

                TestOutputs.Add(result);
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line        = file.ReadLine();
                var input       = Convert.ToInt32(line);
                var sumOfDigits = SumOfDigits(input);

                TestInputs.Add(line);

                if (IsPalindrome(sumOfDigits))
                {
                    TestOutputs.Add("YES");
                }
                else
                {
                    TestOutputs.Add("NO");
                }
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line1     = file.ReadLine();
                var arraySize = Convert.ToInt32(line1);

                var line2    = file.ReadLine();
                var arrayStr = line2;

                TestInputs.Add(line2);

                var result = ConvertToWaveArray(arraySize, arrayStr);

                // Finally add the result to Test outputs
                TestOutputs.Add(result);
            }

            file.Close();
        }
Example #4
0
        public void BuildScaffold()
        {
            const int kmerLength         = 6;
            const int dangleThreshold    = 3;
            const int redundantThreshold = 7;
            var       sequences          = new List <ISequence>(TestInputs.GetReadsForScaffolds());

            KmerLength = kmerLength;
            SequenceReads.Clear();
            this.SetSequenceReads(sequences);
            CreateGraph();

            DanglingLinksThreshold       = dangleThreshold;
            DanglingLinksPurger          = new DanglingLinksPurger(dangleThreshold);
            RedundantPathLengthThreshold = redundantThreshold;
            RedundantPathsPurger         = new RedundantPathsPurger(redundantThreshold);
            UnDangleGraph();
            RemoveRedundancy();

            IList <ISequence> contigs = BuildContigs().ToList();

            CloneLibrary.Instance.AddLibrary("abc", 5, 20);

            using (GraphScaffoldBuilder scaffold = new GraphScaffoldBuilder())
            {
                IEnumerable <ISequence> scaffoldSeq = scaffold.BuildScaffold(sequences, contigs, this.KmerLength, 3, 0);
                HashSet <string>        expected    = new HashSet <string>
                {
                    "ATGCCTCCTATCTTAGCGCGC", "CGCGCCGCGC", "TTTTTT", "CGCGCG", "TTTTAGC", "TTTTTA", "TTTAAA", "TTTTAA",
                };
                AlignmentHelpers.CompareSequenceLists(expected, scaffoldSeq);
            }
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            var noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line = file.ReadLine();
                TestInputs.Add(line);

                var num1 = Convert.ToInt32(line.Split(' ')[0]);
                var num2 = Convert.ToInt32(line.Split(' ')[1]);

                //var lcm = LcmAndGcdByPrimeFactors(num1, num2)[0];
                //var gcd = LcmAndGcdByPrimeFactors(num1, num2)[1];

                var lcm = LcmAndGcdByEuclideanAlgo(num1, num2)[0];
                var gcd = LcmAndGcdByEuclideanAlgo(num1, num2)[1];

                TestOutputs.Add($"{lcm} {gcd}");
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            var noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line  = file.ReadLine();
                var input = Convert.ToInt64(line);
                TestInputs.Add(line);

                Int64 output      = 0;
                var   temp        = input;
                var   order       = Order(input);
                Int64 base10Value = BaseTenToThePower(order);

                while (temp != 0)
                {
                    var digit = temp % 10;
                    output     += (digit * base10Value);
                    base10Value = base10Value / 10;

                    temp = temp / 10;
                }

                TestOutputs.Add(output.ToString());
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line           = file.ReadLine();
                var inputNumberInt = Convert.ToInt32(line);
                TestInputs.Add(line);

                var order = Order(inputNumberInt);
                var sum   = 0;
                var temp  = inputNumberInt;
                while (temp != 0)
                {
                    var digit = temp % 10;
                    sum += Power(digit, order);
                    temp = temp / 10;
                }

                if (sum == inputNumberInt)
                {
                    TestOutputs.Add("Yes");
                }
                else
                {
                    TestOutputs.Add("No");
                }
            }

            file.Close();
        }
Example #8
0
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                // read first line and get array size and rotation size
                var line         = file.ReadLine();
                var arraySize    = line.Split(' ')[0];
                var rotationSize = Convert.ToInt32(line.Split(' ')[1]);

                // read second line and get the input array
                var line2      = file.ReadLine();
                var inputArray = line2;

                TestInputs.Add(line2);

                // rotate it
                var output = RotateArrayBy(inputArray, rotationSize);

                // save it
                TestOutputs.Add(output);
            }

            file.Close();
        }
Example #9
0
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            var noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line  = file.ReadLine();
                var input = Convert.ToInt32(line);

                TestInputs.Add(line);

                if (IsPrime(input))
                {
                    TestOutputs.Add("Yes");
                }
                else
                {
                    TestOutputs.Add("No");
                }
            }

            file.Close();
        }
Example #10
0
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line = file.ReadLine();
                TestInputs.Add(line);

                // Finally add the result to Test outputs
                var result = ReverseWordsWithDot(line);
                TestOutputs.Add(result);
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            var noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line  = file.ReadLine();
                var input = Convert.ToInt32(line);
                TestInputs.Add(line);

                var output = CalculateFactorial(input);
                TestOutputs.Add(output.ToString());
            }

            file.Close();
        }
        public T[,] getTrainWithTestInputs()
        {
            T[,] result = new T[TrainInputs.GetLength(0) + TestInputs.GetLength(0), TrainInputs.GetLength(1)];
            int l = 0;

            for (; l < TrainInputs.GetLength(0); l++)
            {
                for (int j = 0; j < TrainInputs.GetLength(1); j++)
                {
                    result[l, j] = TrainInputs[l, j];
                }
            }
            for (int i = 0; i < TestInputs.GetLength(0); i++, l++)
            {
                for (int j = 0; j < TestInputs.GetLength(1); j++)
                {
                    result[l, j] = TestInputs[i, j];
                }
            }
            return(result);
        }
Example #13
0
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line = file.ReadLine();

                var line2 = file.ReadLine();
                TestInputs.Add(line2);

                // Finally add the result to Test outputs
                var result = FindMissingNumberUsingXor(Convert.ToInt32(line), line2);
                TestOutputs.Add(result.ToString());
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line      = file.ReadLine();
                var inputSize = line;

                var line2 = file.ReadLine();
                TestInputs.Add(line2);
                var inputArrayString = line2;

                // Finally add the result to Test outputs
                var result = RemoveDuplicates(inputArrayString, Convert.ToInt32(inputSize));
                TestOutputs.Add(result);
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            var noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line        = file.ReadLine();
                var binaryInput = Convert.ToInt64(line);
                TestInputs.Add(line);

                Int64 decimalOutput = 0;
                var   temp          = binaryInput;
                var   baseTwoValue  = 1;

                while (temp != 0)
                {
                    // finding least significant bit
                    var lsbOfTemp = temp % 10;

                    // multiplying the lsb with baseTwoVAlue at that position
                    decimalOutput += (lsbOfTemp * baseTwoValue);

                    // moving on to the next digit (towards the left)
                    temp = temp / 10;

                    // increasing the base two value in the same loop
                    baseTwoValue = baseTwoValue * 2;
                }

                TestOutputs.Add(decimalOutput.ToString());
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line      = file.ReadLine();
                var arraySize = Convert.ToInt32(line);

                var line2    = file.ReadLine();
                var arrayStr = line2;

                TestInputs.Add(line2);

                var output = FindMajorityElement(arrayStr);

                TestOutputs.Add(output.ToString());
            }

            file.Close();
        }
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line = file.ReadLine();
                TestInputs.Add(line);

                /*
                 * WRITE YOUR LOGIC HERE
                 * OR
                 * CALL THE FUNCTIONS WRITTEN BELOW
                 */

                // Finally add the result to Test outputs
                TestOutputs.Add("");
            }

            file.Close();
        }
Example #18
0
        public override void Execute()
        {
            var          filePath = $"{TestFilePath}{TestFileName}";
            StreamReader file     = new StreamReader(filePath);

            int noOfTestCases = Convert.ToInt32(file.ReadLine());

            for (int i = 0; i < noOfTestCases; i++)
            {
                var line      = file.ReadLine();
                var arraySize = Convert.ToInt32(line);

                var line2         = file.ReadLine();
                var arrayElements = line2;

                TestInputs.Add(arrayElements);

                var output = ReverseArray(arraySize, arrayElements);

                TestOutputs.Add(output);
            }

            file.Close();
        }