mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 12:50:32 +01:00
Implement day 19 part 1 in Terraform
This commit is contained in:
13
2024/bonus/day19/main.tf
Normal file
13
2024/bonus/day19/main.tf
Normal 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)
|
||||
}
|
||||
@@ -78,3 +78,12 @@ output "day11_1" {
|
||||
output "day11_2" {
|
||||
value = module.day11.part2
|
||||
}
|
||||
|
||||
module "day19" {
|
||||
source = "./day19"
|
||||
input = file("../inputs/19.txt")
|
||||
}
|
||||
|
||||
output "day19_1" {
|
||||
value = module.day19.part1
|
||||
}
|
||||
|
||||
@@ -147,3 +147,20 @@ run "day11" {
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user