Exemplo n.º 1
0
        public static void Main()
        {
            try
            {
                Console.WriteLine(Task1.Solve(ReadFile("input.txt")));
                Console.WriteLine(Task2.BuildFormula(ReadFile("input.txt")));
                Console.WriteLine(Task2.Solve(ReadFile("input.txt")));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.WriteLine("...");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        public static string Solve(IEnumerable <string> input)
        {
            var values = input
                         .First()
                         .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                         .Select(i => int.Parse(i, CultureInfo.InvariantCulture))
                         .ToArray();

            int noun, verb;

            for (noun = 0; noun < values.Length; noun++)
            {
                for (verb = 0; verb < values.Length; verb++)
                {
                    var test = Task1.Solve((int[])values.Clone(), noun, verb);
                    if (test == Output)
                    {
                        return(string.Format("noun={0}; verb={1}; answer={2}", noun, verb, 100 * noun + verb));
                    }
                }
            }

            throw new NotImplementedException();
        }
Exemplo n.º 3
0
 public void Solve(string input, int expected)
 {
     Assert.AreEqual(expected, Task1.Solve(new[] { input }, true));
 }