Exemplo n.º 1
0
        private int symbolsCollected; //indicate how many same symbols of this type in row we already collected

        #endregion Fields

        #region Constructors

        public TreeNode(int index, int max, PhraseCharSet charSet)
        {
            indexOfTheSymbolInPhrase = index;
            maxIndex = max;
            symbolsCollected = 0;
            phraseCharSet = charSet;
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string phrase = "salsita";
            string text = "Yourmissionfortodaywillbe to write a functionthattakestwoparameters: a _phrase_ and a _text_, and calculateshow many timesyoucanfindgiven _phrase_ scatteredacrosstheprovided _text_. I.e. how many timesyoucanfind in the _text_ thefirstcharacterofthe _phrase_ followed (not necessarilyimmediately) with second characterofthe _phrase_, … followedwiththe last characterofthe _phrase_.";
            //string phrase = "abbc";
            //string text = "abbbcbc";

            Console.WriteLine("Your phrase is: " + phrase);
            Console.WriteLine("\nYour text is: " + text);

            var phraseCharSet = new PhraseCharSet(phrase);

            var clock = Stopwatch.StartNew();
            int variantsNumber = PhraseFinder.getScatteredPhraseEntries(phrase, text);
            clock.Stop();

            Console.WriteLine("\nThe number, scattered phrase is met is: " + variantsNumber);
            Console.WriteLine("Time spend: " + clock.ElapsedMilliseconds + " ms.");

            Console.WriteLine("\n\nPress any key to exit...");
            Console.ReadKey();
        }