day4 guard_best_minute duplicate

This commit is contained in:
Xevion
2019-08-04 22:41:11 -05:00
parent 8ed98b062a
commit 9536e361d2

View File

@@ -24,6 +24,7 @@ class GuardData:
guard = max(self.guards.items(), key=lambda item : self.guard_best_minute(item[0])[1])
return guard[0], (self.guard_best_minute(guard[0]))
# Returns the minute the guard selected was asleep the most, along with how much
def guard_best_minute(self, id):
return max(enumerate(self.guards[id]['minutes']), key=lambda i : i[1])
@@ -32,10 +33,6 @@ class GuardData:
best = max(self.guards.items(), key=lambda item : item[1]['total'])
return best[0], best[1]['total']
# Returns the minute the guard selected was asleep the most, along with how much
def guard_best_minute(self, id):
return max(enumerate(self.guards[id]['minutes']), key=lambda item : item[1])
# Simply ensures the guard exists.
# Otherwise, it will initalize a guard with the id.
def ensure_exists(self, id):