Exemplo n.º 1
0
        public void Should_success_test_02()
        {
            var values = new List <string>()
            {
                ResistanceSolver.ConvertToMorse("GOD"),
                ResistanceSolver.ConvertToMorse("GOOD"),
                ResistanceSolver.ConvertToMorse("MORNING"),
                ResistanceSolver.ConvertToMorse("G"),
                ResistanceSolver.ConvertToMorse("HELLO"),
            };

            IDictionary <string, int> dico = new Dictionary <string, int>();

            int maxSize = 0;

            foreach (var value in values)
            {
                var morse = value;
                maxSize = Math.Max(maxSize, morse.Length);

                if (dico.ContainsKey(morse))
                {
                    dico[morse]++;
                }
                else
                {
                    dico[morse] = 1;
                }
            }


            ResistanceSolver solver = new ResistanceSolver(dico, maxSize);

            Assert.AreEqual(1, solver.Compute("--.-------.."));
        }
Exemplo n.º 2
0
            static void Main(string[] args)
            {
                IDictionary <string, int> dico = new Dictionary <string, int>();

                string L = Console.ReadLine();
                int    N = int.Parse(Console.ReadLine());

                int maxSize = 0;

                for (int i = 0; i < N; i++)
                {
                    var morse = ResistanceSolver.ConvertToMorse(Console.ReadLine());
                    maxSize = Math.Max(maxSize, morse.Length);

                    if (dico.ContainsKey(morse))
                    {
                        dico[morse]++;
                    }
                    else
                    {
                        dico[morse] = 1;
                    }
                }

                var solver = new ResistanceSolver(dico, maxSize);

                // Write an action using Console.WriteLine()
                // To debug: Console.Error.WriteLine("Debug messages...");

                Console.WriteLine(solver.Compute(L));
            }
Exemplo n.º 3
0
 public void Shoud_convert_to_morse(string input, string result)
 {
     Assert.AreEqual(result, ResistanceSolver.ConvertToMorse(input));
 }