Created
December 11, 2023 10:37
-
-
Save heidisu/b8505f2502c4e2b2d7617ee08dfe8953 to your computer and use it in GitHub Desktop.
advent of code day 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"times": [7, 15, 30], | |
"distances": [9, 40, 200] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output fra terraform apply