3 input = "11100010111110100"
17 part1 = print $ checksum $ take disk1length $ expand disk1length input
20 part2 = print $ checksum $ take disk2length $ expand disk2length input
23 expand :: Int -> String -> String
26 | otherwise = expand len $ a ++ "0" ++ b
27 where b = map (invert) $ reverse a
31 checksum :: String -> String
33 | odd $ length digits = digits
34 | otherwise = checksum $ map (checksumPair) $ pairs digits
35 where checksumPair p = if (length $ nub p) == 1 then '1' else '0'
40 pairs xs = [p] ++ (pairs ys)
41 where (p, ys) = splitAt 2 xs