Skip to content

Commit c6bbe4b

Browse files
committed
faster
1 parent e70389d commit c6bbe4b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

solutions/src/2024/21.hs

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ shortestDoorCodeLength ::
7171
String {- ^ door code -} ->
7272
Int {- ^ shortest button press count -}
7373
shortestDoorCodeLength n str =
74-
minimum
75-
[ sum (map (shortestRobotCodeLength n) keys)
76-
| keys <- sequence (route doorPad str)
77-
]
74+
sum
75+
[ minimum (map (shortestRobotCodeLength n) keys)
76+
| keys <- route doorPad str
77+
]
7878

7979
-- | The length of the shortest input sequence that enters the given
8080
-- robot directional code via a given number of robot layers.
@@ -84,9 +84,9 @@ shortestRobotCodeLength ::
8484
Int {- ^ shortest button press count -}
8585
shortestRobotCodeLength = memo2 \n str ->
8686
if n == 0 then length str else
87-
minimum
88-
[ sum (map (shortestRobotCodeLength (n-1)) keys)
89-
| keys <- sequence (route robotPad str)
87+
sum
88+
[ minimum (map (shortestRobotCodeLength (n - 1)) keys)
89+
| keys <- route robotPad str
9090
]
9191

9292
-- | Find a list of steps needed to input a code on a pad. The inner

0 commit comments

Comments
 (0)