🎄Advent of Code - Day 4 part 2

This commit is contained in:
Denis-Cosmin Nutiu 2023-12-04 18:33:35 +02:00
parent 4d35c85ea7
commit eb3c41807d

View file

@ -46,6 +46,6 @@ class Scratchcards : Puzzle("2023", "4") {
val parts = card.split("|") val parts = card.split("|")
val cleanParts = parts[1].split(Regex("\\s")).filter { it != "" }.toSet() val cleanParts = parts[1].split(Regex("\\s")).filter { it != "" }.toSet()
val winningNumbers = parts[0].split(":")[1].split(Regex("\\s")).filter { it != "" }.toSet() val winningNumbers = parts[0].split(":")[1].split(Regex("\\s")).filter { it != "" }.toSet()
return winningNumbers.filter { number -> cleanParts.contains(number) }.count() return winningNumbers.count { number -> cleanParts.contains(number) }
} }
} }