do
content <- input 3
let run = Aoc.run content
run (pure 7817) (strategy fault id . lines)
run (pure 2444) (strategy partTwo group . lines)
where
strategy a b = sum . map (priority . a) . b
partTwo = head . foldl1 intersect
type Rucksack = [Item]
type Compartment = [Item]
type Item = Char
type Group = [Rucksack]
error "malformed input"
| isUpper x = lexical_ord + 26
| otherwise = lexical_ord
where
lexical_ord = ord x .&. 0b11111
splitAt half xs
where
half = length xs `shiftR` 1
head . uncurry intersect . compartments
[]
group (a : b : c : xs) = [a, b, c] : group xs