From 967e964f453fc031816270b90d6eab38410769a3 Mon Sep 17 00:00:00 2001 From: Tomasz Chojnacki Date: Fri, 9 Dec 2022 19:31:24 +0100 Subject: Extract common functions to util module --- aoc-2022-dotnet/Day04/Program.fs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'aoc-2022-dotnet/Day04/Program.fs') diff --git a/aoc-2022-dotnet/Day04/Program.fs b/aoc-2022-dotnet/Day04/Program.fs index 2221a4a..7d37d3e 100644 --- a/aoc-2022-dotnet/Day04/Program.fs +++ b/aoc-2022-dotnet/Day04/Program.fs @@ -2,19 +2,20 @@ open System.IO open FParsec +open Common let parseLine line = let prange = pint32 .>> pstring "-" .>>. pint32 let ppair = prange .>> pstring "," .>>. prange .>> eof - Common.parse ppair line + Util.parse ppair line let fullyOverlap ((a, b), (c, d)) = (a <= c && d <= b) || (c <= a && b <= d) let overlapAtAll ((a, b), (c, d)) = a <= d && b >= c -let solution pred = - Seq.map parseLine >> Seq.filter pred >> Seq.length +let solution predicate = + Seq.map parseLine >> Util.countWhere predicate let test = File.ReadLines "test.txt" assert (solution fullyOverlap test = 2) -- cgit v1.2.3