Rename split to splitPair
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user