Skip to content

Instantly share code, notes, and snippets.

@heidisu
Created December 11, 2023 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heidisu/b8505f2502c4e2b2d7617ee08dfe8953 to your computer and use it in GitHub Desktop.
Save heidisu/b8505f2502c4e2b2d7617ee08dfe8953 to your computer and use it in GitHub Desktop.
advent of code day 6
data "local_file" "datafil" {
filename = "test-input.json"
}
locals {
inputdata = jsondecode(data.local_file.datafil.content)
size = length(local.inputdata.times)
speed = [for time in local.inputdata.times: [for i in range(1, time + 1): i * (time - i)]]
records = [for i in range(0, local.size): sum([for speed in local.speed[i]: speed > local.inputdata.distances[i] ? 1 : 0])]
}
output "results" {
value = local.records
}
{
"times": [7, 15, 30],
"distances": [9, 40, 200]
}
@heidisu
Copy link
Author

heidisu commented Dec 11, 2023

Output fra terraform apply

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

results = [
  4,
  8,
  9,
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment