aboutsummaryrefslogtreecommitdiff
path: root/execs/Day14.hs
diff options
context:
space:
mode:
Diffstat (limited to 'execs/Day14.hs')
-rw-r--r--execs/Day14.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/execs/Day14.hs b/execs/Day14.hs
index 7f4368a..e1e0e37 100644
--- a/execs/Day14.hs
+++ b/execs/Day14.hs
@@ -1,15 +1,15 @@
1module Main where 1module Main where
2 2
3import Utils 3import Data.Bifunctor (bimap)
4import Text.ParserCombinators.Parsec
5import Text.Parsec.Char
6import Data.Either
7import Data.Char 4import Data.Char
8import Data.Bifunctor (bimap) 5import Data.Either
6import Data.Map (Map)
7import qualified Data.Map as Map
9import Data.Strings 8import Data.Strings
10import Numeric (showIntAtBase, readInt) 9import Numeric (readInt, showIntAtBase)
11import Data.Map (Map) 10import Text.Parsec.Char
12import qualified Data.Map as Map 11import Text.ParserCombinators.Parsec
12import Utils
13 13
14data Stmt = Mask String | Mem Int Int deriving Show 14data Stmt = Mask String | Mem Int Int deriving Show
15 15
@@ -41,9 +41,9 @@ runProgram ls = sum regs
41 where nval = applyMask val m 41 where nval = applyMask val m
42 42
43floatings :: String -> [String] 43floatings :: String -> [String]
44floatings [] = [[]] 44floatings [] = [[]]
45floatings ('X':xs) = floatings xs >>= (\b -> ['0':b, '1':b]) 45floatings ('X':xs) = floatings xs >>= (\b -> ['0':b, '1':b])
46floatings (x:xs) = map (x:) $ floatings xs 46floatings (x:xs) = map (x:) $ floatings xs
47 47
48genIdxs :: Int -> String -> [Int] 48genIdxs :: Int -> String -> [Int]
49genIdxs v m = map (fst . head . readInt 2 (`elem` "01") digitToInt) (floatings wm) 49genIdxs v m = map (fst . head . readInt 2 (`elem` "01") digitToInt) (floatings wm)