mirror of
https://github.com/Smaug123/AdventOfCode2022
synced 2025-10-22 17:48:39 +00:00
Day 13 (#22)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
namespace AdventOfCode2022
|
||||
|
||||
open System
|
||||
open System.Globalization
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module Day4 =
|
||||
@@ -10,6 +11,9 @@ module Day4 =
|
||||
|
||||
let inline overlaps (a, b) (c, d) : bool = b >= c && a <= d
|
||||
|
||||
let inline private parseInt (c : ReadOnlySpan<char>) : int =
|
||||
Int32.Parse (c, NumberStyles.AllowTrailingWhite)
|
||||
|
||||
let parse (s : ReadOnlySpan<char>) : (int * int) * (int * int) =
|
||||
let commaIndex = s.IndexOf ','
|
||||
let firstElf = s.Slice (0, commaIndex)
|
||||
@@ -20,7 +24,7 @@ module Day4 =
|
||||
let secondDashIndex = secondElf.IndexOf '-'
|
||||
let secondElf1 = secondElf.Slice (0, secondDashIndex)
|
||||
let secondElf2 = secondElf.Slice (secondDashIndex + 1)
|
||||
(Int32.Parse firstElf1, Int32.Parse firstElf2), (Int32.Parse secondElf1, Int32.Parse secondElf2)
|
||||
(parseInt firstElf1, parseInt firstElf2), (parseInt secondElf1, parseInt secondElf2)
|
||||
|
||||
let part1 (lines : StringSplitEnumerator) : int =
|
||||
let mutable count = 0
|
||||
|
Reference in New Issue
Block a user