From 6431f1311284941c542d6fc318feee13dee9e284 Mon Sep 17 00:00:00 2001 From: scarf Date: Sun, 8 Dec 2024 22:27:04 +0900 Subject: [PATCH] refactor: shorter `size.contains` --- 2024/day08.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/2024/day08.scala b/2024/day08.scala index 7031066..c5f2612 100644 --- a/2024/day08.scala +++ b/2024/day08.scala @@ -12,10 +12,9 @@ case class Context(size: Size, antennaes: Map[Char, Vector[Pos]]): antennaes.values.flatMap(_.combinationsN(2).flatMap(fn)).toSet lazy val part1 = - solve((a, b) => Vector(a + (a - b), b + (b - a))).filter(size.contains).size + solve((a, b) => Vector(a + (a - b), b + (b - a))).filter(size(_)).size lazy val part2 = solve((a, b) => - (a deltas b).takeWhile(size.contains) - ++ (b deltas a).takeWhile(size.contains), + (a deltas b).takeWhile(size(_)) ++ (b deltas a).takeWhile(size(_)), ).size object Context: