Skip to content

Commit

Permalink
performance fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 12, 2023
1 parent 9738384 commit cacccd5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions solutions/src/2023/12.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ ways groups springs = answersA ! (0,0)

go groupI springI =
let dotCase = answersA ! (groupI, springI + 1)
hashCase = startGroup groupI (springI + 1)
hashCase = startGroup groupI (springI + 1)
{-# Inline hashCase #-}
in case arrIx springsA springI of
Just '.' -> dotCase
Just '#' -> hashCase
Just '?' -> dotCase + hashCase
Just '?' -> hashCase + dotCase
Nothing | groupI == groupsN -> 1
_ -> 0

Expand All @@ -72,6 +73,7 @@ ways groups springs = answersA ! (0,0)
goGroup groupI n springI =
let doneCase = answersA ! (groupI, springI + 1)
moreCase = goGroup groupI (n-1) (springI + 1)
{-# Inline moreCase #-}
in case arrIx springsA springI of
Just '.' | n == 0 -> doneCase
Just '#' | n > 0 -> moreCase
Expand Down

0 comments on commit cacccd5

Please sign in to comment.