-
-
Save ChiriVulpes/75058852026c82d653fb5398876d62d3 to your computer and use it in GitHub Desktop.
advent of code 2024 chiri solutions day 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// part 1 | |
input.matchAll(/mul\((\d{1,3}),(\d{1,3})\)/g) | |
.map(([m, x, y]) => +x * +y) | |
.reduce((t, c) => t + c, 0) | |
// part 2 | |
input.split(/don't\(\).*?($|do\(\))/gs) | |
.flatMap(input => input.matchAll(/mul\((\d{1,3}),(\d{1,3})\)/g).toArray()) | |
.map(([m, x, y]) => +x * +y) | |
.reduce((t, c) => t + c, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment