Exemplo n.º 1
0
        public override string First(string input)
        {
            Day.LogEnabled = false;
            var intcode = new Intcode();

            intcode.InputQueue.Enqueue(1);
            int[] data = input.GetParts(",").Select(i => int.Parse(i)).ToArray();
            intcode.Execute(data);
            return(intcode.OutputQueue.Last().ToString());
        }
Exemplo n.º 2
0
        public override string First(string input)
        {
            // not 337106 too low - read the question, set noun & verb first!
            Day.LogEnabled = false;
            int[] data    = input.GetParts(",").Select(i => int.Parse(i)).ToArray();
            var   intcode = new Intcode()
            {
                Noun = 12, Verb = 2
            };

            return(intcode.Execute(data)[0].ToString());
        }
Exemplo n.º 3
0
        //public override string FirstTest(string input)
        //{
        //    throw new NotImplementedException("FirstTest");
        //}

        public override string SecondTest(string input)
        {
            Day.ShowInputForOKTest = false;
            Day.LogEnabled         = false;
            var parts     = input.Split(";");
            var inputData = int.Parse(parts[0]);

            input = parts[1];
            var intcode = new Intcode();

            intcode.InputQueue.Enqueue(inputData);
            int[] data = input.GetParts(",").Select(i => int.Parse(i)).ToArray();
            intcode.Execute(data);
            return(intcode.OutputQueue.Last().ToString());
        }
Exemplo n.º 4
0
//        public override string SecondTest(string input)
//        {
//            throw new NotImplementedException("SecondTest");
//        }

        ////////////////////////////////////////////////////////

        public string Solve(int[] data, int target)
        {
            var intcode = new Intcode();

            for (int verb = 14; verb < 100; verb++)
            {
                intcode.Verb = verb;
                for (int noun = 70; noun < 100; noun++)
                {
                    intcode.Noun = noun;
                    if (intcode.Execute(Intcode.CloneData(data))[0] == target)
                    {
                        return(string.Format("{0}{1}", noun, verb));
                    }
                }
            }
            throw new InvalidOperationException("Huh?");
        }
Exemplo n.º 5
0
        public override string FirstTest(string input)
        {
            Day.LogEnabled         = false;
            Day.ShowInputForOKTest = false;
            var parts    = input.Split(";");
            var testtype = parts[0];

            input = parts[1];
            if (testtype == "F")
            {
                return(First(input));
            }
            else
            {
                var   intcode = new Intcode();
                int[] data    = input.GetParts(",").Select(i => int.Parse(i)).ToArray();
                return(intcode.Execute(data)[0].ToString());
            }
        }