mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
28 lines
544 B
HCL
28 lines
544 B
HCL
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)
|
|
}
|