Ejemplo n.º 1
0
        static ulong First(string inputFile)
        {
            var parser       = new InstructionParser();
            var instructions = parser.ReadData(inputFile);

            var         memoryProgram = new MemoryProgram();
            Instruction currentMask   = null;

            foreach (var instruction in instructions)
            {
                if (instruction.Operation == OperationType.Mask)
                {
                    currentMask = instruction;
                    continue;
                }
                var writeValue = ApplyMask1(instruction.Argument2, currentMask.Argument1, currentMask.Argument2);
                memoryProgram.Write(instruction.Argument1, writeValue);
            }
            return(memoryProgram.Memory.Values.Aggregate(0UL, (acc, val) => acc += val));;
        }
Ejemplo n.º 2
0
        public void TestBitConvert(bool[] bits, ulong expectedResult)
        {
            var result = InstructionParser.ToUInt64(new System.Collections.BitArray(bits));;

            Assert.AreEqual(expectedResult, result);
        }