Example #1
0
        public void ParseData_ShouldReturnAddressAndValue_WhenInputIsMemoryAssignment()
        {
            var actual = DockingDataParser.ParseV1("mem[29267] = 4155");

            actual.Address.Should().Be(29267);
            actual.Value.Should().Be(4155);
        }
Example #2
0
        public void CalculateSumV1()
        {
            var input  = File.ReadAllLines("Inputs\\day14.txt");
            var memory = new Memory();

            Memory.ValueMask valueMask = null;

            foreach (var value in input.Where(i => !string.IsNullOrWhiteSpace(i)))
            {
                var parsed = DockingDataParser.ParseV1(value);
                if (parsed.Mask != null)
                {
                    valueMask = parsed.Mask;
                }
                else
                {
                    memory.ApplyValueV1(parsed.Address, valueMask, parsed.Value);
                }
            }

            ulong result = 0;

            foreach (var value in memory.MemoryContents.Values)
            {
                result += value;
            }
            result.Should().Be(17934269678453);
        }
Example #3
0
        public void ParseData_ShouldReturnMask_WhenInputIsMask()
        {
            var actual = DockingDataParser.ParseV1("mask = 110100X1X01011X01X0X000111X00XX1010X");

            actual.Mask.Should().NotBeNull();
        }