Skip to content

Commit

Permalink
use lambdacase
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 27, 2024
1 parent a009ae3 commit 439d1c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions solutions/src/2024/21.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# Language BlockArguments, ImportQualifiedPost #-}
{-# Language BlockArguments, LambdaCase, ImportQualifiedPost #-}
{-|
Module : Main
Description : Day 21 solution
Expand Down Expand Up @@ -80,9 +80,9 @@ shortRobotCode ::
Int {- ^ robot layers -} ->
String {- ^ robot arrows code -} ->
Int {- ^ shortest button press count -}
shortRobotCode = memo2 \n ->
if n == 0 then length else
sum . map (minimum . map (shortRobotCode (n - 1))) . route robotPad
shortRobotCode = memo2 \case
0 -> length
n -> sum . map (minimum . map (shortRobotCode (n - 1))) . route robotPad

-- | Find a list of steps needed to input a code on a pad. The inner
-- lists allow for there to be multiple, valid subsequences that exist
Expand Down

0 comments on commit 439d1c2

Please sign in to comment.