Encode() 공개 정적인 메소드

public static Encode ( string input ) : string
input string
리턴 string
예제 #1
0
    public void Encode_with_single_values()
    {
        const string input    = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB";
        const string expected = "12WB12W3B24WB";

        Assert.That(RunLengthEncoding.Encode(input), Is.EqualTo(expected));
    }
예제 #2
0
    public void Encode_and_then_decode()
    {
        const string input    = "zzz ZZ  zZ";
        const string expected = "zzz ZZ  zZ";

        Assert.That(RunLengthEncoding.Decode(RunLengthEncoding.Encode(input)), Is.EqualTo(expected));
    }
예제 #3
0
    public void Encode_unicode()
    {
        const string input    = "⏰⚽⚽⚽⭐⭐⏰";
        const string expected = "⏰3⚽2⭐⏰";

        Assert.That(RunLengthEncoding.Encode(input), Is.EqualTo(expected));
    }
예제 #4
0
파일: Encoder.cs 프로젝트: ZalkinV/CT.Lab1
        public static IList <byte> RLE(IList <byte> bytes)
        {
            var rle       = new RunLengthEncoding(bytes);
            var rleResult = rle.Encode();

            return(rleResult);
        }
예제 #5
0
        public void NewIntRunLengthEncoding()
        {
            int length = (int)dataStack.Pop();
            RunLengthEncoding <int> enc = RunLengthEncoding <int> .Encode(YieldValues <int>(length));

            dataStack.Push(enc);
        }
예제 #6
0
        public void NewByteRunLengthEncoding()
        {
            int length = (int)dataStack.Pop();
            RunLengthEncoding <byte> enc = RunLengthEncoding <byte> .Encode(YieldValues <byte>(length));

            dataStack.Push(enc);
        }
        public void EncodingTest(string input, string expected)
        {
            var    target = new RunLengthEncoding();
            string actual = target.Encode(input);

            Assert.That(actual, Is.EqualTo(expected));
        }
예제 #8
0
    public void Encode_simple()
    {
        const string input    = "AABBBCCCC";
        const string expected = "2A3B4C";

        Assert.That(RunLengthEncoding.Encode(input), Is.EqualTo(expected));
    }
예제 #9
0
    public void Encode_unicode()
    {
        const string input    = "⏰⚽⚽⚽⭐⭐⏰";
        const string expected = "⏰3⚽2⭐⏰";

        Assert.Equal(expected, RunLengthEncoding.Encode(input));
    }
예제 #10
0
        private static void RunLengthEncodingTest()
        {
            string input = "AAAABBBCCDAE";

            WriteLine("RunLengthEncoding");

            string encodedOutput = RunLengthEncoding.Encode(input);

            WriteLine($"Input : {input} , Encoded : {encodedOutput}");

            string decodedOutput = RunLengthEncoding.Decode(encodedOutput);

            WriteLine($"Input : {input} , Decoded : {decodedOutput}");

            WriteLine(input == decodedOutput);
        }
예제 #11
0
 public void Run_length_encode_a_string_single_characters_only_are_encoded_without_count()
 {
     Assert.Equal("XYZ", RunLengthEncoding.Encode("XYZ"));
 }
예제 #12
0
        public void EncodeTestNormalInput()
        {
            RunLengthEncoding target = new RunLengthEncoding();

            Assert.AreEqual("3A2B4C", target.Encode("AAABBCCCC"));
        }
예제 #13
0
 public void Encode_empty_string()
 {
     Assert.Equal("", RunLengthEncoding.Encode(""));
 }
예제 #14
0
        public void EncodeTestLowercase()
        {
            RunLengthEncoding target = new RunLengthEncoding();

            Assert.AreEqual("2a3b4c", target.Encode("aabbbcccc"));
        }
예제 #15
0
        public void EncodeTestStringAndSpaces()
        {
            RunLengthEncoding target = new RunLengthEncoding();

            Assert.AreEqual("2 3AB", target.Encode("  AAAB"));
        }
예제 #16
0
 public void test_encode_lowercase_characters()
 {
     Assert.AreEqual("2a3b4c", RunLengthEncoding.Encode("aabbbcccc"));
 }
예제 #17
0
 public void test_combination()
 {
     Assert.AreEqual("zzz ZZ  zZ", RunLengthEncoding.Decode(RunLengthEncoding.Encode("zzz ZZ  zZ")));
 }
예제 #18
0
        public void EncodeTestNoRepeats()
        {
            RunLengthEncoding target = new RunLengthEncoding();

            Assert.AreEqual("ABC", target.Encode("ABC"));
        }
예제 #19
0
 public void test_encode_single_characters_mixed_with_repeated_characters()
 {
     Assert.AreEqual("12WB12W3B24WB", RunLengthEncoding.Encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"));
 }
예제 #20
0
 public void Run_length_encode_a_string_empty_string()
 {
     Assert.Equal("", RunLengthEncoding.Encode(""));
 }
예제 #21
0
 public void Run_length_encode_a_string_multiple_whitespace_mixed_in_string()
 {
     Assert.Equal("2 hs2q q2w2 ", RunLengthEncoding.Encode("  hsqq qww  "));
 }
예제 #22
0
 public void Run_length_encode_a_string_string_with_no_single_characters()
 {
     Assert.Equal("2A3B4C", RunLengthEncoding.Encode("AABBBCCCC"));
 }
예제 #23
0
        static void Main(string[] args)
        {
            SortedMatrixSearch.Run();
            SparseSearch.Run();
            SearchInRotatedArray.Run();
            GroupAnagrams.Run();
            CombinationsOfNPairsParentheses.Run();
            PermutationWithDuplicates.Run();
            PermutationNoDuplicates.Run();

            var subsetList = new List <List <int> >();

            subsetList = SubsetInSet.FindAllSubsetInSet(new List <int> {
                1, 2, 3
            });
            ReverseLinkedList.Run();
            IsUniqueString.Run();
            StoneDivisionProblem.Run();
            Kangaroo.Run();
            AppleAndOrange.Run();
            AbbreviationProblem.Run();
            FibonacciModifiedProblem.Run();
            RecursiveDigitSum.Run();
            RangeSumOfBST.Run();
            GradingStudentsProblem.Run();
            // XorSequenceProblem.Run();
            CounterGameProblem.Run();
            MaximizingXORProblem.Run();
            LonelyIntegerProblem.Run();
            FlippingBitsProblem.Run();
            QueueUsingTwoStacksProblem.Run();
            GetNodeValue.Run();
            MergeTwoSortedLinkedLists.Run();
            Compare_Two_linked_lists.Run();

            DeleteNodeProblem.Run();
            ArrayManipulationProblem.Run();
            LeftRotationProblem.Run();
            HourGlass2D.Run();
            SimpleTextEditorProblem.Run();
            EqualStacksProblem.Run();
            MaximumElementProblem.Run();
            BinarySearchTreeInsertion.Run();
            TopViewProblem.Run();
            TimeConvertsionProblem.Run();
            BinaryTreePathsProblem.Run();
            IncreasingOrderSearchTree.Run();
            RemoveAllAdjacentDuplicatesInStringWithKLength.Run();
            RemoveAllAdjacentDuplicatesInString.Run();
            CheckStraightLineProblem.Run();
            HouseRobber.Run();
            UniquePathsProblem.Run();
            FirstUniqueCharacterInString.Run();
            BinaryTreeInorderTraversal.Run();
            DailyTemperaturesProblem.Run();
            CountingBitsproblem.Run();
            SortIntegersByTheNumberOf1BitsProblem.Run();
            HammingDistanceProblem.Run();
            RansomNoteProblem.Run();
            ConvertBinaryNumberInLinkedListToIntegerProblem.Run();
            NumberOfStepsToReduceNumberToZeroProblem.Run();
            JewelsAndStones.Run();
            ClimbingStairsProblem.Run();
            BestTimeToBuyAndSellStock.Run();
            MajorityElementProblem.Run();
            MoveZeroesProblem.Run();
            InvertBinaryTree.Run();
            SingleNumberProblem.Run();
            MaximumDepthInTrree.Run();
            MergeTwoBinaryTrees.Run();
            AddBinaryProblem.Run();
            PlusOneProblem.Run();
            LengthOfLastWordProblem.Run();
            KadaneAlgorithmForMaxSubArray.Run();
            KMPAlgorithm.Run();
            CountAndSayProblem.Run();
            SearchInsertPosition.Run();
            ImplementIndexOfString.Run();
            RemoveElement.Run();
            RemoveDuplicatesFromSortedArray.Run();
            MergeTwoSortedLists.Run();
            ValidParentheses.Run();
            LongestCommonPrefix.Run();
            RomanToInteger.Run();
            PalindromeNumber.Run();
            ReverseInteger.Run();
            TwoSumProblem.Run();
            AddOneToNumber.Run();
            MostAmountOfChange.Run();
            #region BinaryTree
            LeastCommonAncestor.Run();
            PrintAllPaths.Run();
            HasPathSum.Run();
            CheckIfBinaryTreeIsBinarySearchTree.Run();
            PrintAllNodesWithRangeInBinarySearchTree.Run();
            UniqueTreeStructureNumber.Run();
            MirrorTree.Run();
            #region BitManuiplation_GetNthNumber
            NumberOfStepsToReduceNumberToZeroProblem.Run();
            CountNumbersOf1InBit.Run();
            ReverseThebitsInInteger.Run();
            PrintBitsInInteger.Run();
            GetNthBit.Run();
            setNthBitTo1.Run();
            SetNthBitTo0.Run();
            #endregion
            MinimumtValueInTrree minValueInTree = new MinimumtValueInTrree();
            minValueInTree.Run();
            #endregion

            #region Recursion
            Chessboard chessboard = new Chessboard();
            chessboard.Run();
            RatPathToMaze ratPathToMaze = new RatPathToMaze();
            ratPathToMaze.Run();
            List <string> anagramList = new List <string>();
            anagramList        = WordAnagram.GenerateWordAnagram("abc");
            Pixel[,] pixelList = new Pixel[3, 3] {
                { new Pixel(0, 0, "red"), new Pixel(0, 1, "green"), new Pixel(0, 2, "green") },
                { new Pixel(1, 0, "red"), new Pixel(1, 1, "green"), new Pixel(1, 2, "green") },
                { new Pixel(2, 0, "red"), new Pixel(2, 1, "green"), new Pixel(2, 2, "green") }
            };
            FillPaint.PaintFill(pixelList, 1, 2, "green", "black");

            BinaryTreesAreTheSame.Run();

            #endregion

            #region General problems
            RotateArrayByKSpaces.Run();

            #region AddtwoNumbersReferencedByTheirDigits
            var addRes = AddtwoNumbersReferencedByTheirDigits.AddNumbers(new int[] { 1, 2, 7 }, new int[] { 9, 4 });
            #endregion

            #region RunLengthEncoding
            var encodedStr = RunLengthEncoding.Encode("aabbbbc");
            var decodedStr = RunLengthEncoding.Decode(encodedStr);
            #endregion

            #region BreakDocumentIntoChunk
            var chunkRes = BreakDocumentIntoChunk.Chunkify("ab:dd:ddfcct:aab:cccc", ':', 5);
            #endregion

            #region GameOfLife
            var gameRes = GameOfLife.GetNextInteration(new int[3, 3] {
                { 1, 0, 0 }, { 0, 1, 1 }, { 1, 0, 0 }
            });
            #endregion .

            #endregion


            #region InsertionSort
            InsertionSort.insertionSort(listToSort);
            #endregion

            #region BinarySearch
            Console.WriteLine(String.Format("%s is present at index: %s", 30, BinarySearch.binarySearch(sortedArray, 30, 0, sortedArray.Length - 1)));
            Console.WriteLine(String.Format("%s is present at index: %s", 4, BinarySearch.binarySearch(sortedArray, 4, 0, sortedArray.Length - 1)));
            Console.WriteLine(String.Format("%s is present at index: %s", 15, BinarySearch.binarySearch(sortedArray, 15, 0, sortedArray.Length - 1)));
            #endregion


            #region MergeSort
            MergeSort.print(listToSort);
            MergeSort.mergeSort(listToSort);
            #endregion


            #region QuickSort
            QuickSort.print(listToSort);
            QuickSort.quickSort(listToSort, 0, listToSort.Length - 1);
            QuickSort.print(listToSort);
            #endregion
        }
예제 #24
0
        public void EncodeAndDecodeTest()
        {
            RunLengthEncoding target = new RunLengthEncoding();

            Assert.AreEqual("zzz ZZ  zZ", target.Decode(target.Encode("zzz ZZ  zZ")));
        }
예제 #25
0
 public void Run_length_encode_a_string_single_characters_mixed_with_repeated_characters()
 {
     Assert.Equal("12WB12W3B24WB", RunLengthEncoding.Encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"));
 }
예제 #26
0
 public void test_encode_empty_string()
 {
     Assert.AreEqual("", RunLengthEncoding.Encode(""));
 }
예제 #27
0
 public void Run_length_encode_a_string_lowercase_characters()
 {
     Assert.Equal("2a3b4c", RunLengthEncoding.Encode("aabbbcccc"));
 }
예제 #28
0
 public void test_encode_single_characters_only_are_encoded_without_count()
 {
     Assert.AreEqual("XYZ", RunLengthEncoding.Encode("XYZ"));
 }
예제 #29
0
 public void Encode_and_then_decode_encode_followed_by_decode_gives_original_string()
 {
     Assert.Equal("zzz ZZ  zZ", RunLengthEncoding.Decode(RunLengthEncoding.Encode("zzz ZZ  zZ")));
 }
예제 #30
0
 public void test_encode_string_with_no_single_characters()
 {
     Assert.AreEqual("2A3B4C", RunLengthEncoding.Encode("AABBBCCCC"));
 }