From: Ummon Date: Tue, 12 Dec 2017 12:31:18 +0000 (+0100) Subject: Cleaning X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=2864b614f2ed03bd64d34e60990112040dfc9ebd;p=advent_of_code_2017.git Cleaning --- diff --git a/AdventOfCode2017/Day12.fs b/AdventOfCode2017/Day12.fs index 34c0e46..bc636b7 100644 --- a/AdventOfCode2017/Day12.fs +++ b/AdventOfCode2017/Day12.fs @@ -11,7 +11,6 @@ let parseInput (lines : string[]) : Map> = ) Map.empty let graphCount (g : Map>) = - let rec visit (current : int) (visited : Set) : Set = if visited |> Set.contains current then Set.empty @@ -19,9 +18,6 @@ let graphCount (g : Map>) = seq { yield g.[current]; for neighbor in g.[current] -> visit neighbor (visited |> Set.add current) } |> Set.unionMany let rec nbRoots (vertices : Set) = - if Set.isEmpty vertices then - 0 - else - 1 + nbRoots (vertices - (visit (vertices |> Set.minElement) Set.empty)) + if Set.isEmpty vertices then 0 else 1 + nbRoots (vertices - (visit (vertices |> Set.minElement) Set.empty)) visit 0 Set.empty |> Set.count, g |> Map.toList |> List.map fst |> Set.ofList |> nbRoots \ No newline at end of file