Day eight: Use Flow for more sane piping
This commit is contained in:
@@ -4,10 +4,11 @@ import Common (Position, readWorld, multiMapFromList, pairPermutations)
|
||||
import qualified Data.Map.Strict as Map
|
||||
import qualified Data.Set as Set
|
||||
import Control.Monad (join)
|
||||
import Flow
|
||||
|
||||
task1 :: String -> Int
|
||||
task1 input = case readWorld input of
|
||||
((width, height), antennas) -> length $ Set.fromList $ filter isInWorld $ join $ map antinodesOfFrequency $ Map.elems $ multiMapFromList antennas
|
||||
((width, height), antennas) -> multiMapFromList antennas |> Map.elems |> map antinodesOfFrequency |> join |> filter isInWorld |> Set.fromList |> length
|
||||
where
|
||||
antinodesOfFrequency :: [Position] -> [Position]
|
||||
antinodesOfFrequency nodes = pairPermutations nodes >>= antinodesOfPair
|
||||
|
||||
Reference in New Issue
Block a user