Skip to content

Instantly share code, notes, and snippets.

@ChiriVulpes
Created December 6, 2024 09:32
Show Gist options
  • Save ChiriVulpes/75058852026c82d653fb5398876d62d3 to your computer and use it in GitHub Desktop.
Save ChiriVulpes/75058852026c82d653fb5398876d62d3 to your computer and use it in GitHub Desktop.
advent of code 2024 chiri solutions day 3
// 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