delete intersections entirely because we play golf
This commit is contained in:
parent
e64af48b80
commit
8cfca9295e
|
@ -24,11 +24,9 @@ step x
|
|||
| x=='L'=V2 (-1) 0
|
||||
|
||||
day3a :: [V2 Int] -> [V2 Int] -> Int
|
||||
day3a xs ys = Set.findMin $ Set.map manhattan (intersections xs ys)
|
||||
day3a xs ys = Set.findMin $ Set.map manhattan $
|
||||
(Set.fromList xs) `Set.intersection` (Set.fromList ys)
|
||||
where manhattan (V2 x y) = abs x + abs y
|
||||
|
||||
intersections :: [V2 Int] -> [V2 Int] -> Set.Set (V2 Int)
|
||||
intersections xs ys = (Set.fromList xs) `Set.intersection` (Set.fromList ys)
|
||||
|
||||
day3b xs ys = minimum [let f = succ . fromJust . elemIndex x in
|
||||
f xs + f ys | x<-Set.toList $ intersections xs ys]
|
||||
day3b xs ys = minimum [let f = succ . fromJust . elemIndex x in f xs + f ys
|
||||
| x<-Set.toList $ (Set.fromList xs) `Set.intersection` (Set.fromList ys)]
|
||||
|
|
Loading…
Reference in New Issue