module advent_of_code.tasks.day_3.Star1 open System.IO let stream = new StreamReader("tasks/day-3/input.txt") let getJoltage (line: string) = let firstDigit = List.max(Seq.toList(line[0 .. line.Length - 2])) let firstDigitPos = line.IndexOf firstDigit let secondDigit = List.max(Seq.toList(line[firstDigitPos + 1 ..])) $"{firstDigit}{secondDigit}" |> int let rec mainLoop (lines: string list) = let line, tail = lines.Head, lines.Tail let joltage = getJoltage line if (tail.IsEmpty) then joltage else joltage + mainLoop tail let rec main = let lines = stream.ReadToEnd().Split("\n") |> Array.toList mainLoop lines