Day 7, part 1 - minor adjustments
This commit is contained in:
parent
a58f59b31f
commit
91d0fb46bc
6
7.hs
6
7.hs
|
@ -1,11 +1,9 @@
|
||||||
import Data.HashSet (Set, fromList, delete)
|
import Data.HashSet (Set, fromList, delete)
|
||||||
import Data.List.Split
|
import Data.List.Split
|
||||||
import Debug.Trace
|
|
||||||
|
|
||||||
type Weight = Int
|
type Weight = Int
|
||||||
type Program = String
|
type Program = String
|
||||||
type Programs = [Program]
|
type Programs = [Program]
|
||||||
--type Tree = Map Program (Weight, Programs)
|
|
||||||
|
|
||||||
discardEmpty :: [String] -> [String]
|
discardEmpty :: [String] -> [String]
|
||||||
discardEmpty [""] = []
|
discardEmpty [""] = []
|
||||||
|
@ -22,10 +20,10 @@ main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
input <- readFile "7.txt"
|
input <- readFile "7.txt"
|
||||||
let list = map parseLine $ lines input
|
let list = map parseLine $ lines input
|
||||||
names = fromList $ map (\(name, _, _) -> name) list
|
nameSet = fromList $ map (\(name, _, _) -> name) list
|
||||||
bottom = foldr (\(name, _, programs) set ->
|
bottom = foldr (\(name, _, programs) set ->
|
||||||
case programs of
|
case programs of
|
||||||
[] -> delete name set
|
[] -> delete name set
|
||||||
ps -> foldr delete set ps)
|
ps -> foldr delete set ps)
|
||||||
names list
|
nameSet list
|
||||||
print $ bottom
|
print $ bottom
|
Loading…
Reference in New Issue