From: Greg Burri Date: Tue, 12 Dec 2017 05:37:07 +0000 (+0100) Subject: Cleaning X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=a5750e7b0ea2459842e74008aa130d7564be2cbd;p=advent_of_code_2017.git Cleaning --- diff --git a/AdventOfCode2017/Day12.fs b/AdventOfCode2017/Day12.fs index 0a61c9b..8d840f1 100644 --- a/AdventOfCode2017/Day12.fs +++ b/AdventOfCode2017/Day12.fs @@ -13,11 +13,11 @@ type Graph = let parseInput (lines : string[]) : (Graph * string[]) list = [ for line in lines do - let a = line.Split ([| ' '; ',' |], StringSplitOptions.RemoveEmptyEntries) - yield { Name = a.[0]; Neighbors = List () }, a.[2 .. a.Length - 1] + let splitLine = line.Split ([| ' '; ',' |], StringSplitOptions.RemoveEmptyEntries) + yield { Name = splitLine.[0]; Neighbors = List () }, splitLine.[2 .. splitLine.Length - 1] ] -let f (input : (Graph * string[]) list) = +let graphCount (input : (Graph * string[]) list) = let toVisit = Dictionary () for g, names in input do @@ -28,7 +28,7 @@ let f (input : (Graph * string[]) list) = g'.Neighbors.Add (g) g.Neighbors.Add (g') - let visited = List> () + let visitedGroups = List> () let rec visit (g : Graph) (dic : Dictionary) = if dic.ContainsKey g.Name |> not then @@ -39,8 +39,8 @@ let f (input : (Graph * string[]) list) = while toVisit.Count > 0 do let dic = Dictionary () - visited.Add dic + visitedGroups.Add dic visit (toVisit.First().Value) dic - visited.First().Count, visited.Count + visitedGroups.First().Count, visitedGroups.Count