static void Main(string[] args)
        {
            //string[] lines = System.IO.File.ReadAllLines(@"WordList.txt", Encoding.GetEncoding("ISO-8859-2"));

            //Array.Sort(lines, (x, y) => x.Length.CompareTo(y.Length));
            //using (System.IO.StreamWriter file =
            //new System.IO.StreamWriter(@"WordList_LengthSort.txt", false, Encoding.GetEncoding("ISO-8859-2")))
            //{
            //    foreach (string line in lines)
            //    {
            //        file.WriteLine(line);
            //    }
            //}

            var rezultati = new List <string> {
                ""
            };

            var options = new ParallelOptions();

            options.MaxDegreeOfParallelism = 3;
            Parallel.ForEach(rezultati, options, (item) =>
            {
                var watch = System.Diagnostics.Stopwatch.StartNew();

                var anagram = new AnagramLib.Anagram();

                int smallWordCount = item.Length > 12 ? 0 : 1;

                var result = anagram.MultipleWordAnagramWith(item, "", smallWordCount);

                watch.Stop();
                //var elapsedMs = watch.Elapsed.;

                using (System.IO.StreamWriter file =
                           new System.IO.StreamWriter(item + ".txt", false, Encoding.Unicode))
                {
                    file.WriteLine("Duration(days hours:minutes:seconds) "
                                   + watch.Elapsed.Days + " "
                                   + watch.Elapsed.Hours + ":"
                                   + watch.Elapsed.Minutes + ":"
                                   + watch.Elapsed.Seconds);

                    foreach (string line in result)
                    {
                        file.WriteLine(line);
                    }
                }
            }
                             );

            //var anagram = new AnagramLib.Anagram();

            //var result = anagram.MultipleWordAnagramWith("ante caktaš", "", 1);

            //Debugger.Break();
        }
Exemple #2
0
        public void MultipleWordAnagramTest1()
        {
            var anagram = new AnagramLib.Anagram();

            var result = anagram.MultipleWordAnagramWith("Gospin dolac", "", 5);

            Assert.NotNull(result);
            Assert.True(result.Count > 0);
        }
Exemple #3
0
        public void OneWordTest2()
        {
            var anagram = new AnagramLib.Anagram();

            var result = anagram.OneWordAnagram("ititraž");

            Assert.NotNull(result);
            Assert.Equal(result.Count, 1);
            Assert.Equal(result[0], "tražiti");
        }
Exemple #4
0
        public void OneWordTest1()
        {
            var anagram = new AnagramLib.Anagram();

            var result = anagram.OneWordAnagram("etst");

            Assert.NotNull(result);
            Assert.Equal(result.Count, 1);
            Assert.Equal(result[0], "test");
        }
Exemple #5
0
        public void Initialize()
        {
            var data = new AnagramLib.Anagram();

            Assert.NotNull(data.WordList);
        }