From 89d895a08ce6055bba3649f3178e76c3e5170ae3 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sat, 17 Dec 2016 11:23:45 +0000 Subject: [PATCH] More tidying --- advent17.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/advent17.hs b/advent17.hs index c99b8da..d8be772 100644 --- a/advent17.hs +++ b/advent17.hs @@ -61,13 +61,14 @@ successors state = [Agendum {position = step p0 ld, legalDoors = filter (isLegalPos . (step p0)) doors openDoors :: String -> String -openDoors h = (u h) ++ (d h) ++ (l h) ++ (r h) - -u h = if h!!0 `elem` "bcdef" then "U" else "" -d h = if h!!1 `elem` "bcdef" then "D" else "" -l h = if h!!2 `elem` "bcdef" then "L" else "" -r h = if h!!3 `elem` "bcdef" then "R" else "" - +openDoors h = up ++ down ++ left ++ right + where + up = if h!!0 `elem` "bcdef" then "U" else "" + down = if h!!1 `elem` "bcdef" then "D" else "" + left = if h!!2 `elem` "bcdef" then "L" else "" + right = if h!!3 `elem` "bcdef" then "R" else "" + +step :: Position -> Char -> Position step (r, c) 'U' = (r-1, c) step (r, c) 'D' = (r+1, c) step (r, c) 'L' = (r, c-1) -- 2.34.1