mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 22:00:31 +01:00
Implement day 4 in Terraform
This commit is contained in:
27
2024/bonus/day04/check_point/check_xmas/main.tf
Normal file
27
2024/bonus/day04/check_point/check_xmas/main.tf
Normal file
@@ -0,0 +1,27 @@
|
||||
variable "grid" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "x" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "y" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "dx" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "dy" {
|
||||
type = number
|
||||
}
|
||||
|
||||
locals {
|
||||
match = [for i in range(4) : var.x + i * var.dx >= 0 && try(substr(var.grid[var.y + i * var.dy], var.x + i * var.dx, 1), "F") == substr("XMAS", i, 1)]
|
||||
}
|
||||
|
||||
output "found" {
|
||||
value = alltrue(local.match) ? 1 : 0
|
||||
}
|
||||
Reference in New Issue
Block a user