Implement day 19 part 1 in Terraform

This commit is contained in:
2024-12-19 23:24:11 +01:00
parent dd07090056
commit fdaadfe184
3 changed files with 39 additions and 0 deletions

13
2024/bonus/day19/main.tf Normal file
View File

@@ -0,0 +1,13 @@
variable "input" {
type = string
}
locals {
parts = split("\n\n", chomp((var.input)))
patterns = replace(local.parts[0], ", ", "|")
valid = [for line in split("\n", local.parts[1]) : line if length(regexall("^(${local.patterns})+$", line)) > 0]
}
output "part1" {
value = length(local.valid)
}

View File

@@ -78,3 +78,12 @@ output "day11_1" {
output "day11_2" { output "day11_2" {
value = module.day11.part2 value = module.day11.part2
} }
module "day19" {
source = "./day19"
input = file("../inputs/19.txt")
}
output "day19_1" {
value = module.day19.part1
}

View File

@@ -147,3 +147,20 @@ run "day11" {
error_message = "Part1 output is wrong" error_message = "Part1 output is wrong"
} }
} }
run "day19" {
command = plan
module {
source = "./day19"
}
variables {
input = file("../tests/samples/19.txt")
}
assert {
condition = output.part1 == 6
error_message = "Part1 output is wrong"
}
}