예제 #1
0
    public override string Part2(string input, object?args)
    {
        var pool = new ReceiverPool();

        foreach (var line in input.Lines())
        {
            Instructions.ApplyInstruction(pool, line);
        }

        var arr = args as int[];
        var res = 1;

        foreach (var outp in arr)
        {
            res *= pool.Outputs[outp].Chips[0];
        }
        return(res.ToString());
    }
예제 #2
0
    public override string Part1(string input, object?args)
    {
        var pool = new ReceiverPool();
        var arr  = args as int[];

        _chip1 = arr[0];
        _chip2 = arr[1];

        Instructions.OnBotComparing += Instructions_OnBotComparing;
        foreach (var line in input.Lines())
        {
            Instructions.ApplyInstruction(pool, line);
            if (_comparingBotFound)
            {
                break;
            }
        }

        return(_comparingBot.Id.ToString());
    }
예제 #3
0
        public static void Main(string[] args)
        {
            var          pool  = new ReceiverPool();
            const string input = Generic.Input;

            foreach (var line in input.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                Instructions.ApplyInstruction(pool, line);
            }


            //Print output contents
            foreach (var o in pool.Outputs.OrderBy(x => x.Key))
            {
                Console.Write(o.Key + " : ");
                o.Value.Chips.ForEach(x => Console.Write(x + ","));
                Console.WriteLine();
            }

            Console.ReadKey();
        }