diff --git a/AdventOfCode2018/Day01.cs b/AdventOfCode2018/Day01.cs index bd3f6ec..8172c3a 100644 --- a/AdventOfCode2018/Day01.cs +++ b/AdventOfCode2018/Day01.cs @@ -1,6 +1,4 @@ -using System; - -namespace AdventOfCode2018 +namespace AdventOfCode2018 { /* --- Day 1: Chronal Calibration --- @@ -33,12 +31,28 @@ namespace AdventOfCode2018 Starting with a frequency of zero, what is the resulting frequency after all of the changes in frequency have been applied? */ - public class Day01 { public string ResolveDay01(string[] inputs) { - throw new NotImplementedException(); + int accumulator = 0; + foreach (string input in inputs) + { + int intInput; + if (int.TryParse(input.Substring(1), out intInput)) + { + if (input[0] == '-') + { + accumulator -= intInput; + } + if (input[0] == '+') + { + accumulator += intInput; + } + } + } + + return accumulator.ToString(); } } }