Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        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}");
        }