From ab2b7213c5568e02bf8fc3b2c6b7f3560699ab17 Mon Sep 17 00:00:00 2001 From: Smaug123 Date: Thu, 7 Dec 2023 23:34:28 +0000 Subject: [PATCH] Formt --- .../AdventOfCode2023.FSharp.Lib/Day7.fs | 2 ++ .../AdventOfCode2023.FSharp.Lib/ResizeArray.fs | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day7.fs b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day7.fs index 5611048..f270677 100644 --- a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day7.fs +++ b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day7.fs @@ -96,8 +96,10 @@ module Day7 = else let mutable jokerCount = 0 let mutable jokerPos = 0 + while jokerPos < tallyBuffer.Count && jokerCount = 0 do let card, tally = tallyBuffer.[jokerPos] + if card = joker then jokerCount <- tally else diff --git a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/ResizeArray.fs b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/ResizeArray.fs index 5b69e9c..8436b68 100644 --- a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/ResizeArray.fs +++ b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/ResizeArray.fs @@ -5,12 +5,13 @@ open System type ResizeArray<'T> = private { - mutable Array: 'T array - mutable Length: int + mutable Array : 'T array + mutable Length : int } member this.Count = this.Length member this.Clear () = this.Length <- 0 + member this.Add (t : 'T) = if this.Length < this.Array.Length then this.Array.[this.Length] <- t @@ -20,7 +21,9 @@ type ResizeArray<'T> = Array.blit this.Array 0 newArray 0 this.Length newArray.[this.Length] <- t this.Array <- newArray + this.Length <- this.Length + 1 + member this.Item with get (i : int) = this.Array.[i] and set (i : int) (t : 'T) = this.Array.[i] <- t @@ -30,4 +33,8 @@ type ResizeArray<'T> = [] module ResizeArray = - let create<'T> (capacity : int) = { Array = Array.zeroCreate<'T> capacity; Length = 0 } + let create<'T> (capacity : int) = + { + Array = Array.zeroCreate<'T> capacity + Length = 0 + }