예제 #1
0
파일: Program.cs 프로젝트: Stydla/AOC2020
 private void ProcessLine2(Memory2 memory, string line)
 {
     if (line.StartsWith("mask"))
     {
         string tmp = line.Replace("mask = ", "");
         memory.ProcessMask(tmp);
     }
     else if (line.StartsWith("mem"))
     {
         Match      m     = Regex.Match(line, "mem\\[(\\d*)\\] = (\\d*)");
         BigInteger index = BigInteger.Parse(m.Groups[1].Value);
         BigInteger val   = BigInteger.Parse(m.Groups[2].Value);
         memory.ProcessValue(index, val);
     }
 }
예제 #2
0
파일: Program.cs 프로젝트: Stydla/AOC2020
        public override string SolveTask2(string InputData)
        {
            Data    data   = new Data(InputData);
            Memory2 memory = new Memory2();

            while (!data.IsEnd())
            {
                string line = data.Next();

                ProcessLine2(memory, line);
            }

            BigInteger res = memory.SumValues();

            return($"{res}");
        }