예제 #1
0
        public void IsUnique_EmptyString_Test()
        {
            BruteForceSolution bruteForceSolution = new BruteForceSolution();
            var  inputString = string.Empty;
            bool actual      = bruteForceSolution.IsUnique(inputString);

            Assert.AreEqual(true, actual);
        }
예제 #2
0
        public void IsUnique_LargeInput_Test()
        {
            BruteForceSolution bruteForceSolution = new BruteForceSolution();

            var  inputString = StringUtilities.CreateLargeString();
            bool actual      = bruteForceSolution.IsUnique(inputString);

            Trace.WriteLine(inputString);
            Trace.WriteLine(actual);
        }
예제 #3
0
        public void IsUnique_SmallInput_NotUnique_Test_3()
        {
            BruteForceSolution bruteForceSolution = new BruteForceSolution();

            var  inputString = "gghjyer";
            bool expectedAllCharactersUnique = false;
            bool actualAllCharactersUnique   = bruteForceSolution.IsUnique(inputString);

            Assert.AreEqual(expectedAllCharactersUnique, actualAllCharactersUnique);
        }
예제 #4
0
    public static void Main()
    {
        // ===========================================================
        // Test 0 o negativo: entre 2 a 100 piedras, 100 comparaciones
        // ===========================================================

        /*
         * {
         *  LocateTheTimeStone g = new LocateTheTimeStone(0);
         *  InteractiveTest(g);
         * }
         */


        // ===========================================================
        // Test 1: 10 piedras, 100 comparaciones
        // ===========================================================
        {
            Solution           s = new BruteForceSolution();
            LocateTheTimeStone g = new LocateTheTimeStone(1);
            int answer           = s.Solve(g);
            g.VerifyAnswer(answer);
            Console.WriteLine(
                "Test {0}  OK  #Comparisons: {1} of {2}",
                1, g.CurNumComparisons, g.MaxNumComparisons);
        }


        // ===========================================================
        // Test 2: 10 piedras, todas falsas, 100 comparaciones
        // ===========================================================
        {
            Solution           s = new BruteForceSolution();
            LocateTheTimeStone g = new LocateTheTimeStone(1);
            int answer           = s.Solve(g);
            g.VerifyAnswer(answer);
            Console.WriteLine(
                "Test {0}  OK  #Comparisons: {1} of {2}",
                2, g.CurNumComparisons, g.MaxNumComparisons);
        }


        // ===========================================================
        // Tests 3-100: 1000 piedras, 1000 comparaciones
        // ===========================================================
        for (int testNum = 3; testNum <= 100; testNum++)
        {
            Solution           s = new YourSolution();
            LocateTheTimeStone g = new LocateTheTimeStone(testNum);
            int answer           = s.Solve(g);
            g.VerifyAnswer(answer);
            Console.WriteLine(
                "Test {0}  OK  #Comparisons: {1} of {2}",
                testNum, g.CurNumComparisons, g.MaxNumComparisons);
        }


        // ===========================================================
        // Tests 101-200: 1000 piedras, 501 comparaciones
        // ===========================================================
        for (int testNum = 101; testNum <= 200; testNum++)
        {
            Solution           s = new YourSolution();
            LocateTheTimeStone g = new LocateTheTimeStone(testNum);
            int answer           = s.Solve(g);
            g.VerifyAnswer(answer);
            Console.WriteLine(
                "Test {0}  OK  #Comparisons: {1} of {2}",
                testNum, g.CurNumComparisons, g.MaxNumComparisons);
        }


        // ===========================================================
        // Tests 201-300: 10000 piedras, 15 comparaciones
        // ===========================================================
        for (int testNum = 201; testNum <= 300; testNum++)
        {
            Solution           s = new YourSolution();
            LocateTheTimeStone g = new LocateTheTimeStone(testNum);
            int answer           = s.Solve(g);
            g.VerifyAnswer(answer);
            Console.WriteLine(
                "Test {0}  OK  #Comparisons: {1} of {2}",
                testNum, g.CurNumComparisons, g.MaxNumComparisons);
        }


        // ===========================================================
        // Tests 301-400: 100000 piedras, 15 comparaciones
        // ===========================================================

        for (int testNum = 301; testNum <= 400; testNum++)
        {
            Solution           s = new YourSolution();
            LocateTheTimeStone g = new LocateTheTimeStone(testNum);
            int answer           = s.Solve(g);
            g.VerifyAnswer(answer);
            Console.WriteLine(
                "Test {0}  OK  #Comparisons: {1} of {2}",
                testNum, g.CurNumComparisons, g.MaxNumComparisons);
        }


        // ===========================================================
        // Tests 401-500: 1000000 piedras, 15 comparaciones
        // ===========================================================

        for (int testNum = 401; testNum <= 500; testNum++)
        {
            Solution           s = new YourSolution();
            LocateTheTimeStone g = new LocateTheTimeStone(testNum);
            int answer           = s.Solve(g);
            g.VerifyAnswer(answer);
            Console.WriteLine(
                "Test {0}  OK  #Comparisons: {1} of {2}",
                testNum, g.CurNumComparisons, g.MaxNumComparisons);
        }



        // ===========================================================
        // Tests 401-500: 10000000 piedras, 17 comparaciones
        // ===========================================================

        for (int testNum = 501; testNum <= 600; testNum++)
        {
            Solution           s = new YourSolution();
            LocateTheTimeStone g = new LocateTheTimeStone(testNum);
            int answer           = s.Solve(g);
            g.VerifyAnswer(answer);
            Console.WriteLine(
                "Test {0}  OK  #Comparisons: {1} of {2}",
                testNum, g.CurNumComparisons, g.MaxNumComparisons);
        }
    }