public void PrintPermutations_PermuteOne()
        {
            var output = StringPermutation.Permute("A");

            Assert.AreEqual(1, output.Count);
            Assert.AreEqual("A", output[0]);
        }
        public void PrintPermutations_PermuteEmpty()
        {
            var output = StringPermutation.Permute(string.Empty);

            Assert.AreEqual(1, output.Count);
            Assert.AreEqual(string.Empty, output[0]);
        }
        public void PrintPermutations_PermuteNull()
        {
            var output = StringPermutation.Permute(null);

            Assert.AreEqual(1, output.Count);
            Assert.AreEqual(null, output[0]);
        }
Ejemplo n.º 4
0
        private static bool CheckStringPermutation()
        {
            StringPermutation sp   = new StringPermutation();
            string            str1 = "kunal";
            string            str2 = "unakl";

            return(sp.CheckTwoStringsArePermutationOfEachOther(str1, str2));
        }
Ejemplo n.º 5
0
 private static void Main(string[] args)
 {
     CheckPerforamance(() =>
     {
         var excersise = new StringPermutation();
         excersise.Permutation("abcdefghm", "");
     }, "Permutation");
 }
        public void PrintPermutations_PermuteTwo()
        {
            var output = StringPermutation.Permute("AB");

            Assert.AreEqual(2, output.Count);
            Assert.IsTrue(output.Contains("AB"));
            Assert.IsTrue(output.Contains("BA"));
        }
 public void PrintPermutations_PermuteOne()
 {
     var output = new TestOutput();
     var strPerm = new StringPermutation("A", output);
     strPerm.PrintPermutations();
     Assert.AreEqual(1, output.Container.Count);
     Assert.AreEqual("A", output.Container[0]);
 }
Ejemplo n.º 8
0
        public void PrintPermutations_PermuteOne()
        {
            var output  = new TestOutput();
            var strPerm = new StringPermutation("A", output);

            strPerm.PrintPermutations();
            Assert.AreEqual(1, output.Container.Count);
            Assert.AreEqual("A", output.Container[0]);
        }
 public void PrintPermutations_PermuteTwo()
 {
     var output = new TestOutput();
     var strPerm = new StringPermutation("AB", output);
     strPerm.PrintPermutations();
     Assert.AreEqual(2, output.Container.Count);
     Assert.IsTrue(output.Container.Contains("AB"));
     Assert.IsTrue(output.Container.Contains("BA"));
 }
Ejemplo n.º 10
0
        public void PrintPermutations_PermuteTwo()
        {
            var output  = new TestOutput();
            var strPerm = new StringPermutation("AB", output);

            strPerm.PrintPermutations();
            Assert.AreEqual(2, output.Container.Count);
            Assert.IsTrue(output.Container.Contains("AB"));
            Assert.IsTrue(output.Container.Contains("BA"));
        }
        public void PrintPermutations_PermuteThree()
        {
            var output = StringPermutation.Permute("ABC");

            Assert.AreEqual(6, output.Count);
            Assert.IsTrue(output.Contains("ABC"));
            Assert.IsTrue(output.Contains("ACB"));
            Assert.IsTrue(output.Contains("BAC"));
            Assert.IsTrue(output.Contains("BCA"));
            Assert.IsTrue(output.Contains("CAB"));
            Assert.IsTrue(output.Contains("CBA"));
        }
Ejemplo n.º 12
0
        public void GivenTwoStrings_WhenRun_ThenReturnsCountOfAllPermutationsOfTheShorterStringWithinTheLongerOne()
        {
            // Arrange
            var p    = new StringPermutation();
            var str  = "abbc";
            var text = "cbabadcbbabbcbabaabccbabc";

            // Act
            var result = p.GetPermutationCount(str, text);

            // Assert
            Assert.AreEqual(7, result);
        }
        public void FindPermutationSuccess()
        {
            var result = StringPermutation.FindPermutation("oidbcaf", "abc");

            Assert.Equal(result, true);


            result = StringPermutation.FindPermutation("oidbcaf", "abc");
            Assert.Equal(result, true);


            result = StringPermutation.FindPermutation("bcdxabcdy", "bcdyabcdx");
            Assert.Equal(result, true);
        }
Ejemplo n.º 14
0
        public void GivenString_WhenRun_ThenReturnsAllPermutationsOfAGivenString()
        {
            // Arrange
            var p        = new StringPermutation();
            var str      = "abc";
            var expected = new HashSet <string>(new[] { "abc", "bac", "cab", "acb", "bca", "cba" });

            // Act
            var result = p.Permutate(str);

            // Assert
            Assert.AreEqual(expected.Count, result.Count);
            result.ForEach(x => expected.Remove(x));
            Assert.AreEqual(0, expected.Count);
        }
Ejemplo n.º 15
0
 static void Main(string[] args)
 {
     Console.WriteLine(String.Format("Has all unique characters for {0}? The answer is: {1}", "mondaym", HasAllUniqueCharacters.HasAllUniqueCharatersWithDS("mondaym")));
     ReverseString.reverse("thisiscorrect");
     Console.WriteLine(String.Format("{0} is permutation of {1}: {2}", "danliu", "uinlda", StringPermutation.IsPermutation("danliu", "uinlda")));
     Console.WriteLine(String.Format("{0} is permutation of {1}: {2}", "danliu", "sophia", StringPermutation.IsPermutation("danliu", "sophia")));
     ReplacWhiteSpaceWith20Percent.ReplaceWhiteSpaceWith20("Mr. John Smith");
     StringCompression.CompressString("aabcccccaaa");
     StringCompression.CompressString("abcdefgg");
     int[,] imageOrignal = new int[2, 2] {
         { 1, 2 }, { 3, 4 }
     };
     RotateImage.Rotate(imageOrignal);
     int[,] m1 = new int[3, 3] {
         { 1, 2, 5 }, { 3, 1, 0 }, { 0, 4, 7 }
     };
     SetZeroToMatrix.SetZeroToRowAndColumn(m1);
     Console.WriteLine(WordRotation.IsWordRotation("erbottlewat", "Waterbottle"));
     Console.WriteLine(WordRotation.IsWordRotation("Waterbottle", "erbettoewti"));
 }
Ejemplo n.º 16
0
 static void Main(string[] args)
 {
     var combination = StringCombination.DoStringCombination("aabc");
     var permutation = StringPermutation.DoStringPermutation("aabc");
 }