diff --git a/2022/app/Day3/Main.hs b/2022/app/Day3/Main.hs index 3db019d..c609ac7 100644 --- a/2022/app/Day3/Main.hs +++ b/2022/app/Day3/Main.hs @@ -20,13 +20,12 @@ main = do type Rucksack = (String, String) parseData :: String -> [Rucksack] -parseData input = compartments +parseData input = zip firstCompartments secondCompartments where rucksacks = lines input compartmentSize = map ((`div` 2) . length) rucksacks - firstCompartments = map (\(s, r) -> take s r) (zip compartmentSize rucksacks) - secondCompartments = map (\(s, r) -> drop s r) (zip compartmentSize rucksacks) - compartments = zip firstCompartments secondCompartments + firstCompartments = map (uncurry take) (zip compartmentSize rucksacks) + secondCompartments = map (uncurry drop) (zip compartmentSize rucksacks) inBoth :: Eq a => [a] -> [a] -> [a] inBoth a b = [x | x <- a, y <- b, x == y]