Day 5 - Part 2
This commit is contained in:
parent
640efa334b
commit
19975730a5
1 changed files with 7 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
-- import Debug.Trace (trace)
|
||||
import Data.List (sort)
|
||||
|
||||
binaryPartitionWalker :: String -> Int -> Int -> (String, Int, Int)
|
||||
binaryPartitionWalker ('F':s) begin end =
|
||||
|
@ -29,6 +30,9 @@ seatID str = row * 8 + seat
|
|||
solvePart1 :: [String] -> Int
|
||||
solvePart1 = maximum . (map seatID)
|
||||
|
||||
solvePart2 :: [String] -> Int
|
||||
solvePart2 = fst . head . (filter (\(x,y) -> x /= y)) . (zip [13..]) . sort . (map seatID)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStrLn "Day 5 - Part 1"
|
||||
|
@ -36,6 +40,8 @@ main = do
|
|||
print $ seatID "BFFFBBFRRR"
|
||||
print $ seatID "FFFBBBFRRR"
|
||||
print $ seatID "BBFFBBFRLL"
|
||||
putStrLn $ "Solution of part 1"
|
||||
input <- lines <$> readFile "day5/input"
|
||||
putStrLn $ "Solution of part 1"
|
||||
print $ solvePart1 input
|
||||
putStrLn $ "Solution of part 2"
|
||||
print $ solvePart2 input
|
||||
|
|
Loading…
Reference in a new issue