コード例 #1
0
        public void FromFileDataSet()
        {
            var charactersBoardRetriever = new SampleBoardRetriever();
            var wordsDictionary          = new DictionaryOfWordsRetrieverFromFile("sample-dictionary-french.txt");
            var logger = new EmptyLogger();

            var boardAnalyzer = new DefaultBoardAnalyzer(wordsDictionary, charactersBoardRetriever, logger);

            boardAnalyzer.Initialize().Wait();

            var timer = new Stopwatch();

            timer.Start();

            var result = boardAnalyzer.Analyze().Result;

            timer.Stop();

            var detectedWords = result.OrderBy(x => x.Key).ToArray();

            Console.WriteLine($"Found {detectedWords.Length} words in {timer.ElapsedMilliseconds}ms");

            foreach (var detectedWord in detectedWords)
            {
                var coordinates = detectedWord.Value.Select(x => x.ToString());
                Console.WriteLine($"{detectedWord.Key} with path: {string.Join(" -> ", coordinates)}");
            }

            Assert.IsTrue(timer.ElapsedMilliseconds < 10000);
        }
コード例 #2
0
        static void Main()
        {
            var lines = new List <char[]>();

            Console.WriteLine("Enter 1st line");
            var l1 = Console.ReadLine();

            lines.Add(GetLineAsCharArray(l1));

            Console.WriteLine("Enter 2nd line");
            var l2 = Console.ReadLine();

            lines.Add(GetLineAsCharArray(l2));

            Console.WriteLine("Enter 3rd line");
            var l3 = Console.ReadLine();

            lines.Add(GetLineAsCharArray(l3));

            Console.WriteLine("Enter 4th line");
            var l4 = Console.ReadLine();

            lines.Add(GetLineAsCharArray(l4));

            var boardAsCharArray = lines.ToArray();
            var board            = new ConsoleBoardRetriever(boardAsCharArray);
            var wordsDictionary  = new DictionaryOfWordsRetrieverFromFile("dictionary.txt");

            var logger = new EmptyLogger();

            var boardAnalyzer = new DefaultBoardAnalyzer(wordsDictionary, board, logger);

            boardAnalyzer.Initialize().Wait();

            var timer = new Stopwatch();

            timer.Start();

            var result = boardAnalyzer.Analyze().Result;

            timer.Stop();

            var detectedWords = result.OrderByDescending(x => x.Key.Length).ToArray();

            Console.WriteLine($"Found {detectedWords.Length} words in {timer.ElapsedMilliseconds}ms");

            foreach (var detectedWord in detectedWords)
            {
                var coordinates = detectedWord.Value.Select(x => x.ToString());
                Console.WriteLine($"{detectedWord.Key} with path: {string.Join(" -> ", coordinates)}");

                PrintBoardDetectedWords(boardAsCharArray, detectedWord.Key, detectedWord.Value);

                Console.WriteLine("Click to get next solution");
                Console.ReadKey();
            }
        }
コード例 #3
0
        public void TestMethod1()
        {
            var charactersBoardRetriever = new SampleBoardRetriever();
            var wordsDictionary          = new SampleDictionaryOfWordsRetriever();
            var logger = new EmptyLogger();

            var boardAnalyzer = new DefaultBoardAnalyzer(wordsDictionary, charactersBoardRetriever, logger);

            boardAnalyzer.Initialize().Wait();

            var timer = new Stopwatch();

            timer.Start();

            var result = boardAnalyzer.Analyze().Result;

            timer.Stop();

            Debug.WriteLine($"Duration : {timer.ElapsedMilliseconds}ms");

            Assert.IsTrue(result.ContainsKey("geeks"));
            Assert.IsTrue(result.ContainsKey("quiz"));
            Assert.AreEqual(result.Count, 2);
        }