public override object SolvePart2(string input) { var timeSheet = TimeSheet.CalculateTimesheet(input); var sleepTimesPerGuardMinute = from guard in timeSheet.AllGuardIds() from st in timeSheet.DaysAsleepPerMinute(guard) select(guard, st.minute, st.asleepCount); var sleepiestMinute = sleepTimesPerGuardMinute.OrderByDescending(x => x.asleepCount) .First(); return(sleepiestMinute.minute * sleepiestMinute.guard); }
public override object SolvePart1(string input) { var timeSheet = TimeSheet.CalculateTimesheet(input); var guardsTotalSleepTimes = from guard in timeSheet.AllGuardIds() select(guard, sleepTime: timeSheet.GuardTotalSleepMinutes(guard)); var sleepiestGuard = guardsTotalSleepTimes.OrderByDescending(x => x.sleepTime) .First() .guard; var sleepMatrix = timeSheet.DaysAsleepPerMinute(sleepiestGuard); var sleepiestMinute = sleepMatrix.OrderByDescending(x => x.asleepCount) .First(); return(sleepiestGuard * sleepiestMinute.minute); }
public Day1804_TimesheetTests() { var observations = new Day1804Solution().GetPart1SampleInputs().First(); TimeSheet = TimeSheet.CalculateTimesheet(observations); }