示例#1
0
        public void FromInput()
        {
            const int expectedOutput = 19690720;

            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "input.txt";

            var input = Utilities.EmbeddedResource.Get(resourceName, assembly);

            var optCodes = input.Split(",")
                           .Select(int.Parse)
                           .ToArray();

            var nouns = Enumerable.Range(0, 99);
            var verbs = Enumerable.Range(0, 99);

            Parallel.ForEach(nouns, noun =>
            {
                Parallel.ForEach(verbs, verb =>
                {
                    var cache = new int[optCodes.Length];
                    System.Array.Copy(optCodes, cache, optCodes.Length);
                    cache[1] = noun;
                    cache[2] = verb;

                    OptCodeComputer.Output(ref cache);

                    if (cache[0] == expectedOutput)
                    {
                        System.Console.WriteLine($"waaaa noun {noun} - verb {verb} result = {100 * noun + verb}");
                    }
                });
            });
        }
示例#2
0
        public void FromExample(string integers, string expectedResult)
        {
            var optCodes = integers.Split(",")
                           .Select(int.Parse)
                           .ToArray();

            OptCodeComputer.Output(ref optCodes);

            string.Join(',', optCodes).Should().Be(expectedResult);
        }
示例#3
0
        public void FromInput()
        {
            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "input.txt";

            var input = Utilities.EmbeddedResource.Get(resourceName, assembly);

            var optCodes = input.Split(",")
                           .Select(int.Parse)
                           .ToArray();

            OptCodeComputer.Output(ref optCodes);

            optCodes.First().Should().Be(5534943);
        }