mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 22:00:31 +01:00
Implement 2024 day 3 part 2 in Terraform
No one's going to stop me, not even common sense
This commit is contained in:
@@ -4,8 +4,21 @@ variable "input" {
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user