diff --git a/2021/day08/day08.hs b/2021/day08/day08.hs index 381cc2c..5dcf5aa 100644 --- a/2021/day08/day08.hs +++ b/2021/day08/day08.hs @@ -9,17 +9,15 @@ main = do print $ length $ filter (`elem` [2,3,4,7]) $ map length (concat output) print $ day08 input - --- string auf int hashmap machen? findDict :: [String] -> M.Map Char Char findDict wire = M.fromList $ zip (a++b++c++d++e++f++g) "abcdefg" - where a = intersect (getX 3) (without [2,4]) --done - b = intersect (charsWithLength 3 6) (charsWithLength 1 5) --done? - c = intersect (charsWithLength 2 6) (getX 2) --done? - d = intersect (charsWithLength 2 6) (charsWithLength 3 5) --done? - e = intersect (charsWithLength 1 5) $ intersect (getX 7) $ without [2..4] --done? - f = getX 2 \\ c --done - g = without [2..4] \\ e --done? + where a = intersect (getX 3) (without [2,4]) + b = intersect (charsWithLength 3 6) (charsWithLength 1 5) + c = intersect (charsWithLength 2 6) (getX 2) + d = intersect (charsWithLength 2 6) (charsWithLength 3 5) + e = intersect (charsWithLength 1 5) $ intersect (getX 7) $ without [2..4] + f = getX 2 \\ c + g = without [2..4] \\ e without x = "abcdefg" \\ (concat $ filter (flip elem x . length) wire) getXs x = filter (\y->length y == x) wire getX = head . getXs