static void Main(string[] args) { string inputText = System.IO.File.ReadAllText(@"input.txt"); string[] orderedInputText = inputText.Split('\n').OrderBy(str => str.Split(' ', 1)[0]).ToArray(); GuardsInfo guardsInfo = new GuardsInfo(orderedInputText); SleepiestGuard mostSleepy = new SleepiestGuard(guardsInfo); SleepiestMinuteGuard mostSleepyMinuteGuard = new SleepiestMinuteGuard(guardsInfo); int mostSleepyKey = mostSleepy.GetSleepiestGuardId(); int mostSleepyMinute = mostSleepy.GetSleepiestGuardMinute(); int mostSleepyMinuteGuardKey = mostSleepyMinuteGuard.GetSleepiestMinuteGuardId(); int mostSleepyMinuteGuardMinute = mostSleepyMinuteGuard.GetSleepiestMinuteGuard(); string results = Program.FormatResults(mostSleepyKey, mostSleepyMinute, mostSleepyMinuteGuardKey, mostSleepyMinuteGuardMinute); System.IO.File.WriteAllText("results.json", results); }
public SleepiestMinuteGuard(GuardsInfo guardsInfo) { this.GuardsInfo = guardsInfo; this.SleepiestGuardInfo = new Lazy<KeyValuePair<int, int>>(this.InitSleepiestGuardInfo); }