day 11 part 1 in terraform

This commit is contained in:
2024-12-11 18:53:06 +01:00
parent 023807a701
commit 2beccdd0e6
5 changed files with 230 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
variable "prev" {
type = list(number)
}
locals {
values = [
for num in var.prev : num == 0 ? [1]
: length(tostring(num)) % 2 == 0
? [tonumber(substr(tostring(num), 0, length(tostring(num)) / 2)), tonumber(substr(tostring(num), length(tostring(num)) / 2, 10))]
: [num * 2024]
]
}
# module "transform" {
# source = "../transform"
# count = length(var.prev)
# num = var.prev[count.index]
# }
# output "next" {
# value = flatten(module.transform[*].result)
# }
output "next" {
value = flatten(local.values)
}