My Haskell solution for today was quite short, but performance was shit.
importqualifiedData.Map.StrictasMapsolve::Int->Map.MapIntInt->Int->Int->Intsolvelimitmemtprev|t==limit=prev|otherwise=caseMap.lookupprevmemofNothing->solvelimit(Map.insertprev(t-1)mem)(t+1)0Justt'->solvelimit(Map.insertprev(t-1)mem)(t+1)(t-t'-1)main=doletinput=[20,0,1,11,6,3]-- 436initMemory=Map.fromList$zip(initinput)[1..]print$solve2021initMemory(lengthinput+1)(lastinput)print$solve30000001initMemory(lengthinput+1)(lastinput)-- Runtime about 1:20m for part 2.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My Haskell solution for today was quite short, but performance was shit.