mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 13:50:32 +01:00
Implement day 5 part 1 in terraform
I'm pretty sure part 2 is impossible
This commit is contained in:
21
2024/bonus/day05/is_correct/main.tf
Normal file
21
2024/bonus/day05/is_correct/main.tf
Normal file
@@ -0,0 +1,21 @@
|
||||
variable "update" {
|
||||
type = list(number)
|
||||
}
|
||||
|
||||
variable "disallow_rules" {
|
||||
type = map(list(number))
|
||||
}
|
||||
|
||||
locals {
|
||||
not_disallowed = alltrue([
|
||||
for i in range(1, length(var.update)) :
|
||||
!contains(
|
||||
flatten([for j in range(i) : lookup(var.disallow_rules, var.update[j], [])]),
|
||||
var.update[i]
|
||||
)
|
||||
])
|
||||
}
|
||||
|
||||
output "valid" {
|
||||
value = local.not_disallowed ? var.update[floor(length(var.update) / 2)] : 0
|
||||
}
|
||||
Reference in New Issue
Block a user