示例#1
0
        static void Main(string[] args)
        {
            // https://app.codility.com/programmers/lessons/1-iterations/binary_gap/
            //BinaryGap binaryGap = new BinaryGap();
            //Console.WriteLine(binaryGap.solution(1376796946));

            // https://app.codility.com/programmers/lessons/2-arrays/cyclic_rotation/
            //CyclicRotation cyclicRotation = new CyclicRotation();
            //Console.WriteLine(cyclicRotation.solution(new int[] { 3, 8, 9, 7, 6 }, 3));
            //Console.WriteLine(cyclicRotation.solution(new int[] { 1, 2, 3, 4 }, 4));

            // https://app.codility.com/programmers/lessons/2-arrays/odd_occurrences_in_array/
            //OddOccurrencesInArray oddOccurrencesInArray = new OddOccurrencesInArray();
            //Console.WriteLine(oddOccurrencesInArray.solution(new int[] { 9, 3, 9, 3, 9, 7, 9 }));

            // https://app.codility.com/programmers/lessons/3-time_complexity/perm_missing_elem/
            //PermMissingElem permMissingElem = new PermMissingElem();
            //Console.WriteLine(permMissingElem.solution(new int[] { 2, 3, 1, 5 }));

            // https://app.codility.com/programmers/lessons/3-time_complexity/frog_jmp/
            //FrogJmp frogJmp = new FrogJmp();
            //Console.WriteLine(frogJmp.solution(10, 85, 30));

            // https://app.codility.com/programmers/lessons/3-time_complexity/tape_equilibrium/
            //TapeEquilibrium tapeEquilibrium = new TapeEquilibrium();
            //Console.WriteLine(tapeEquilibrium.solution(new int[] { 3, 1, 2, 4, 3 }));

            // https://app.codility.com/programmers/lessons/4-counting_elements/perm_check/
            PermCheck permCheck = new PermCheck();

            Console.WriteLine(permCheck.solution(new int[] { 3, 1, 2, 4 }));
        }
示例#2
0
 static void Main(string[] args)
 {
     Console.WriteLine("Hello World!");
     Console.WriteLine(BinaryGap.Solution(529));
     foreach (var item in CyclicRotation.Solution(new int[] { 3, 8, 9, 7, 6 }, 3))
     {
         Console.Write(item + " ");
     }
     Console.WriteLine();
     Console.WriteLine(OddOccurrencesInArray.Solution(new int[] { 4, 5, 6, 4, 5, 6, 7 }));
     Console.WriteLine(PermMissingElem.Solution(new int[] { 2, 3, 1, 5 }));
     Console.WriteLine(FrogJmp.Solution(10, 100, 30));
     Console.WriteLine(TapeEquilibrium.Solution(new int[] { 3, 1, 2, 4, 3 }));
     Console.WriteLine(PermCheck.Solution(new int[] { 2, 3, 1, 4, 6 }));
     Console.WriteLine(FrogRiverOne.Solution(5, new int[] { 1, 3, 1, 4, 2, 3, 5, 4 }));
     Console.WriteLine(MissingInteger.Solution(new int[] { 1, 3, 6, 4, 1, 2 }));
     foreach (var item in GenomicRangeQuery.Solution("CAGCCTA", new int[] { 2, 5, 0 }, new int[] { 4, 5, 6 }))
     {
         Console.Write(item + " ");
     }
     Console.WriteLine();
     Console.WriteLine(MaxProductOfThree.Solution(new int[] { 1, 1, 1, -2, -2 }));
     Console.WriteLine(Distinct.Solution(new int[] { 2, 1, 7, 2, 2, 1 }));
     Console.WriteLine(StoneWall.Solution(new int[] { 8, 8, 5, 7, 9, 8, 7, 4, 8 }));
     Console.WriteLine(Dominator.Solution(new int[] { 3, 4, 3, 2, 3, -1, 3, 3 }));
     Console.WriteLine(EquiLeader.Solution(new int[] { 4, 3, 4, 4, 4, 2 }));
     Console.WriteLine(MaxProfit.Solution(new int[] { 23171, 21011, 21123, 21366, 21013, 21367 }));
     Console.WriteLine(MaxSliceSum.Solution(new int[] { 3, 2, -6, 4, 0 }));
     Console.WriteLine(MaxDoubleSliceSum.Solution(new int[] { 3, 2, 6, -1, 4, 5, -1, 2 }));
     Console.WriteLine(Flags.Solution(new int[] { 1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2 }));
     Console.WriteLine(ChocolatesByNumbers.Solution(10, 4));
 }
示例#3
0
 public void TestOne()
 {
     Assert.AreEqual(1, PermCheck.Solution(new int[] { 4, 1, 3, 2 }));
     Assert.AreEqual(0, PermCheck.Solution(new int[] { 4, 1, 3 }));
     Assert.AreEqual(1, PermCheck.Solution(new int[] { 4, 1, 3, 2, 6, 5, 8, 7 }));
     Assert.AreEqual(1, PermCheck.Solution(Helper.GenerateContiguousArray(100, 1)));
     Assert.AreEqual(0, PermCheck.Solution(Helper.GenerateRandomArray(100, 1, 100000)));
     Assert.AreEqual(1, PermCheck.Solution(Helper.GenerateContiguousArray(10000, 1)));
 }
示例#4
0
        public void TestPermCheck(int expected, params int[] A)
        {
            var sol = new PermCheck();

            Assert.AreEqual(expected, sol.solution(A));
        }