Exemple #1
0
        public override void PartOne(IInput input, IOutput output)
        {
            var builder = new StringBuilder();
            var keypad  = new Keypad(new char[, ]
            {
                { '1', '2', '3' },
                { '4', '5', '6' },
                { '7', '8', '9' },
            });
            var position = keypad.FiveKey;

            foreach (var line in input.Lines.AsMemory())
            {
                (var key, position) = FindKey(keypad, line.Span, position);

                builder.Append(key);
            }

            output.WriteProperty("Code", builder.ToString());
        }