| 123456789101112131415161718192021222324 |
- using System.Drawing;
- namespace Day18;
- public record Instruction(char Dir, int Num, byte[] Scramble)
- {
- private static readonly IDictionary<int, char> DirMap = new Dictionary<int, char>
- {
- [0] = 'R',
- [1] = 'D',
- [2] = 'L',
- [3] = 'U'
- };
-
- public Instruction Unscramble()
- {
-
- var code = BitConverter.ToInt32(Scramble.Reverse().Append((byte)0).ToArray());
- var dirIndex = code & 15;
- var num = code >> 4;
- return new Instruction(DirMap[dirIndex], num, new byte[] { });
- }
- }
|