mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
25 lines
484 B
HCL
25 lines
484 B
HCL
variable "input" {
|
|
type = string
|
|
}
|
|
|
|
locals {
|
|
muls = regexall("mul\\((\\d+),(\\d+)\\)", var.input)
|
|
ops = regexall("(don't\\(\\)|do\\(\\)|mul\\((\\d+),(\\d+)\\))", var.input)
|
|
}
|
|
|
|
module "should_execute" {
|
|
count = length(local.ops)
|
|
source = "./should_execute"
|
|
|
|
index = count.index
|
|
ops = local.ops
|
|
}
|
|
|
|
output "part1" {
|
|
value = sum([for mul in local.muls : parseint(mul[1], 10) * parseint(mul[0], 10)])
|
|
}
|
|
|
|
output "part2" {
|
|
value = sum(module.should_execute[*].value)
|
|
}
|