import Data.List.Split
import Data.Char
import Data.Ord
-import Data.Function
main :: IO ()
main = do
print $ part1 layers
putStrLn $ part2 layers
-
imageWidth = 25
imageHeight = 6
part2 layers = unlines rows
where pixelLayers = transpose layers
pixels = map firstVisible pixelLayers
- dPixels = map showPixel pixels
- pixelRows = chunksOf imageWidth dPixels
- rows = map concat pixelRows
-
+ image = concatMap showPixel pixels
+ rows = chunksOf imageWidth image
firstVisible = head . dropWhile (== 2)
showPixel 0 = " "
showPixel 1 = "\x2588"
-
count n = length . filter (== n)
--- Count the number of times a predicate is true
--- (Taken from GHC API utility functions)
-
--- count :: (a -> Bool) -> [a] -> Int
--- count p = go 0
--- where go !n [] = n
--- go !n (x:xs) | p x = go (n+1) xs
--- | otherwise = go n xs
-
-
successfulParse :: String -> [Int]
successfulParse input = map digitToInt input
\ No newline at end of file