-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I've seen your Day 4 solution and your (return) types are quite verbose/unreadable. This can be remedied by defining the types and then using their name.
Something like this:
type
Day = tuple[name: string, times: seq[int]]
Days = seq[Day]
Minutes = array[60, string]
GuardPattern = tuple[date, id: string]
Sleepiest = tuple[total, guard, mostMinute: int]
MostMinutes = tuple[totalCount, current: int]
proc parseInput(input:string): (Table[GuardPattern, Minutes], Days) =
var table = initTable[GuardPattern, Minutes]()
# etc.
proc findGuardThatSleepsMost(days: Days): Sleepiest =
var sleepyHead = ""
let guard = days.map(func(day: Day): string = day[0])
.deduplicate()
.map(func(guard: string): Sleepiest =
let totalMinutes = days
.filter(func(day: Day): bool = day[0] == guard)
.map(func(d: Day): seq[int] = d[1])
.foldl(a.concat(b))
# etc.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels