Rename split to splitPair

This commit is contained in:
zuckerberg
2022-12-04 00:13:50 -07:00
parent 79244532fb
commit 8cb3c32aa5
3 changed files with 7 additions and 7 deletions

View File

@@ -4,10 +4,10 @@ let
# read input
input = readFile ./input;
pairs = let
readRange = s: split (a: b: [ (toInt a) (toInt b) ]) (splitString "-" s);
readRange = s: splitPair (a: b: [ (toInt a) (toInt b) ]) (splitString "-" s);
readPair = a: b: [ (readRange a) (readRange b) ];
in map
(line: split readPair (splitString "," line))
(line: splitPair readPair (splitString "," line))
(splitString "\n" input);
# overlap functions
@@ -20,7 +20,7 @@ let
hasOverlap = overlapFunc: a: b:
let a1 = head a; b1 = head b; a2 = last a; b2 = last b;
in overlapFunc a1 a2 b1 b2 || overlapFunc b1 b2 a1 a2;
overlaps = overlapFunc: map boolToInt (map (split (hasOverlap overlapFunc)) pairs);
overlaps = overlapFunc: map boolToInt (map (splitPair (hasOverlap overlapFunc)) pairs);
in {
part1 = sum (overlaps completeOverlap);
part2 = sum (overlaps partialOverlap);