Fomatting fix
This commit is contained in:
parent
030af6ed8f
commit
cd80733367
@ -3,12 +3,13 @@ with import ../util.nix;
|
|||||||
let
|
let
|
||||||
# read input
|
# read input
|
||||||
input = readFile ./input;
|
input = readFile ./input;
|
||||||
pairs = let
|
pairs =
|
||||||
readRange = s: splitPair (a: b: [ (toInt a) (toInt b) ]) (splitString "-" s);
|
let
|
||||||
readPair = a: b: [ (readRange a) (readRange b) ];
|
readRange = s: splitPair (a: b: [ (toInt a) (toInt b) ]) (splitString "-" s);
|
||||||
in map
|
readPair = a: b: [ (readRange a) (readRange b) ];
|
||||||
(line: splitPair readPair (splitString "," line))
|
in map
|
||||||
(splitString "\n" input);
|
(line: splitPair readPair (splitString "," line))
|
||||||
|
(splitString "\n" input);
|
||||||
|
|
||||||
# overlap functions
|
# overlap functions
|
||||||
partialOverlap = a1: a2: b1: b2:
|
partialOverlap = a1: a2: b1: b2:
|
||||||
@ -18,7 +19,7 @@ let
|
|||||||
|
|
||||||
# calc overlaps
|
# calc overlaps
|
||||||
hasOverlap = overlapFunc: a: b:
|
hasOverlap = overlapFunc: a: b:
|
||||||
splitPair (splitPair overlapFunc a) b || splitPair (splitPair overlapFunc b) a;
|
splitPair (splitPair overlapFunc a) b || splitPair (splitPair overlapFunc b) a;
|
||||||
overlaps = overlapFunc: map boolToInt (map (splitPair (hasOverlap overlapFunc)) pairs);
|
overlaps = overlapFunc: map boolToInt (map (splitPair (hasOverlap overlapFunc)) pairs);
|
||||||
in {
|
in {
|
||||||
part1 = sum (overlaps completeOverlap);
|
part1 = sum (overlaps completeOverlap);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user