Skip to content

Commit 439d1c2

Browse files
committed
use lambdacase
1 parent a009ae3 commit 439d1c2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

solutions/src/2024/21.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# Language BlockArguments, ImportQualifiedPost #-}
1+
{-# Language BlockArguments, LambdaCase, ImportQualifiedPost #-}
22
{-|
33
Module : Main
44
Description : Day 21 solution
@@ -80,9 +80,9 @@ shortRobotCode ::
8080
Int {- ^ robot layers -} ->
8181
String {- ^ robot arrows code -} ->
8282
Int {- ^ shortest button press count -}
83-
shortRobotCode = memo2 \n ->
84-
if n == 0 then length else
85-
sum . map (minimum . map (shortRobotCode (n - 1))) . route robotPad
83+
shortRobotCode = memo2 \case
84+
0 -> length
85+
n -> sum . map (minimum . map (shortRobotCode (n - 1))) . route robotPad
8686

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

0 commit comments

Comments
 (0)