Bones
This commit is contained in:
37
AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day9.fs
Normal file
37
AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day9.fs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace AdventOfCode2023
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module Day9 =
|
||||
|
||||
let parse (s : string) =
|
||||
use mutable lines = StringSplitEnumerator.make '\n' s
|
||||
|
||||
lines.MoveNext () |> ignore
|
||||
|
||||
let stepsLine = lines.Current.TrimEnd ()
|
||||
let steps = Array.zeroCreate stepsLine.Length
|
||||
|
||||
for i = 0 to stepsLine.Length - 1 do
|
||||
steps.[i] <- (stepsLine.[i] = 'R')
|
||||
|
||||
let dict = Dictionary ()
|
||||
|
||||
while lines.MoveNext () do
|
||||
if not lines.Current.IsEmpty then
|
||||
use mutable line = StringSplitEnumerator.make' ' ' lines.Current
|
||||
line.MoveNext () |> ignore
|
||||
{
|
||||
Steps = steps
|
||||
Nodes = dict
|
||||
}
|
||||
|
||||
let part1 (s : string) =
|
||||
let data = parse s
|
||||
answer
|
||||
|
||||
let part2 (s : string) =
|
||||
let data = parse s
|
||||
0
|
Reference in New Issue
Block a user