mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 13:50:32 +01:00
Implement day 2 in Terraform
This commit is contained in:
28
2024/bonus/day02/main.tf
Normal file
28
2024/bonus/day02/main.tf
Normal file
@@ -0,0 +1,28 @@
|
||||
variable "input" {
|
||||
type = string
|
||||
}
|
||||
|
||||
locals {
|
||||
reports = [for line in split("\n", trim(var.input, "\n")) : [for num in split(" ", line) : parseint(num, 10)]]
|
||||
}
|
||||
|
||||
module "part1_valid" {
|
||||
source = "./is_valid"
|
||||
|
||||
count = length(local.reports)
|
||||
report = local.reports[count.index]
|
||||
}
|
||||
|
||||
module "part2_valid" {
|
||||
source = "./is_savable"
|
||||
count = length(local.reports)
|
||||
report = local.reports[count.index]
|
||||
}
|
||||
|
||||
output "part1" {
|
||||
value = length([for i in range(length(local.reports)) : true if module.part1_valid[i].valid])
|
||||
}
|
||||
|
||||
output "part2" {
|
||||
value = length([for i in range(length(local.reports)) : true if module.part2_valid[i].valid])
|
||||
}
|
||||
Reference in New Issue
Block a user