From 439d1c285c826e7bd1dfc279233fa7ab3a68b9ea Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Thu, 26 Dec 2024 20:43:18 -0600 Subject: [PATCH] use lambdacase --- solutions/src/2024/21.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/solutions/src/2024/21.hs b/solutions/src/2024/21.hs index 05372c2..c134a80 100644 --- a/solutions/src/2024/21.hs +++ b/solutions/src/2024/21.hs @@ -1,4 +1,4 @@ -{-# Language BlockArguments, ImportQualifiedPost #-} +{-# Language BlockArguments, LambdaCase, ImportQualifiedPost #-} {-| Module : Main Description : Day 21 solution @@ -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