File tree 1 file changed +13
-11
lines changed
1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -3,26 +3,28 @@ variable "prev" {
3
3
}
4
4
5
5
locals {
6
- not_a_module = {
7
- for num , _ in var . prev : num => (
6
+ by_value = flatten ([
7
+ for num , count in var . prev : (
8
8
tonumber (num) == 0
9
- ? [1 ]
9
+ ? [{ number = 1 , amount = count } ]
10
10
: (
11
11
length (tostring (num)) % 2 == 0
12
12
? [
13
- tonumber (substr (tostring (num), 0 , length (tostring (num)) / 2 )),
14
- tonumber (substr (tostring (num), length (tostring (num)) / 2 , length (tostring (num)) / 2 )),
13
+ {
14
+ number = tonumber (substr (tostring (num), 0 , length (tostring (num)) / 2 )),
15
+ amount = count
16
+ },
17
+ {
18
+ number = tonumber (substr (tostring (num), length (tostring (num)) / 2 , length (tostring (num)) / 2 )),
19
+ amount = count,
20
+ },
15
21
]
16
- : [num * 2024 ]
22
+ : [{ number = 2024 * num, amount = count } ]
17
23
)
18
24
)
19
- }
20
- by_value = flatten ([
21
- for key , value in local . not_a_module :
22
- [for result in value : { num = result, count = var.prev[key] }]
23
25
])
24
26
25
- grouped = { for kv in local . by_value : kv . num => kv . count ... }
27
+ grouped = { for kv in local . by_value : kv . number => kv . amount ... }
26
28
}
27
29
28
30
output "next" {
You can’t perform that action at this time.
0 commit comments