Day 6 and standalone app (#7)

This commit is contained in:
Patrick Stevens
2022-12-06 08:25:16 +00:00
committed by GitHub
parent 0a498ac7d4
commit ef903b33a9
18 changed files with 288 additions and 99 deletions

View File

@@ -22,15 +22,24 @@ module Day4 =
let secondElf2 = secondElf.Slice (secondDashIndex + 1)
(Int32.Parse firstElf1, Int32.Parse firstElf2), (Int32.Parse secondElf1, Int32.Parse secondElf2)
let part1 (lines : string seq) : int =
lines
|> Seq.map (fun s -> parse (s.AsSpan ()))
|> Seq.filter (fun (firstElf, secondElf) -> fullyContains firstElf secondElf || fullyContains secondElf firstElf
)
|> Seq.length
let part1 (lines : StringSplitEnumerator) : int =
let mutable count = 0
let part2 (lines : string seq) : int =
lines
|> Seq.map (fun s -> parse (s.AsSpan ()))
|> Seq.filter (fun (firstElf, secondElf) -> overlaps firstElf secondElf)
|> Seq.length
for line in lines do
let firstElf, secondElf = parse line
if fullyContains firstElf secondElf || fullyContains secondElf firstElf then
count <- count + 1
count
let part2 (lines : StringSplitEnumerator) : int =
let mutable count = 0
for line in lines do
let firstElf, secondElf = parse line
if overlaps firstElf secondElf then
count <- count + 1
count