From 2864b614f2ed03bd64d34e60990112040dfc9ebd Mon Sep 17 00:00:00 2001 From: Ummon Date: Tue, 12 Dec 2017 13:31:18 +0100 Subject: [PATCH] Cleaning --- AdventOfCode2017/Day12.fs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 -- 2.45.2