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.List.Split
|
||||
import Debug.Trace
|
||||
|
||||
type Weight = Int
|
||||
type Program = String
|
||||
type Programs = [Program]
|
||||
--type Tree = Map Program (Weight, Programs)
|
||||
|
||||
discardEmpty :: [String] -> [String]
|
||||
discardEmpty [""] = []
|
||||
|
@ -22,10 +20,10 @@ main :: IO ()
|
|||
main = do
|
||||
input <- readFile "7.txt"
|
||||
let list = map parseLine $ lines input
|
||||
names = fromList $ map (\(name, _, _) -> name) list
|
||||
nameSet = fromList $ map (\(name, _, _) -> name) list
|
||||
bottom = foldr (\(name, _, programs) set ->
|
||||
case programs of
|
||||
[] -> delete name set
|
||||
ps -> foldr delete set ps)
|
||||
names list
|
||||
nameSet list
|
||||
print $ bottom
|
Loading…
Reference in New Issue