diff --git a/2024/bonus/day04/check_point/check_xmas/main.tf b/2024/bonus/day04/check_point/check_xmas/main.tf index ae93c36..5ec6ec9 100644 --- a/2024/bonus/day04/check_point/check_xmas/main.tf +++ b/2024/bonus/day04/check_point/check_xmas/main.tf @@ -19,9 +19,9 @@ variable "dy" { } 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)] + word = join("", [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") : "F"]) } output "found" { - value = alltrue(local.match) ? 1 : 0 + value = contains(["SAMX", "XMAS"], local.word) ? 1 : 0 } diff --git a/2024/bonus/day04/check_point/main.tf b/2024/bonus/day04/check_point/main.tf index af95b21..d75c0e5 100644 --- a/2024/bonus/day04/check_point/main.tf +++ b/2024/bonus/day04/check_point/main.tf @@ -19,9 +19,6 @@ locals { y = floor(var.index / var.width) directions = { - "UL" = [-1, -1] - "U" = [0, -1] - "UR" = [1, -1] "DL" = [-1, 1] "D" = [0, 1] "DR" = [1, 1] diff --git a/2024/bonus/main.tf b/2024/bonus/main.tf index e72a573..45fa707 100644 --- a/2024/bonus/main.tf +++ b/2024/bonus/main.tf @@ -41,8 +41,18 @@ output "day03_2" { value = module.day03.part2 } -# Don't run this, it runs out of memory +# Don't run this, it runs forever (6 minutes) and requires a lot of memory (~5.5GB) to execute to +# boot. Trust me, it works. + # module "day04" { # source = "./day04" # input = file("../inputs/04.txt") # } + +# output "day04_1" { +# value = module.day04.part1 +# } + +# output "day04_2" { +# value = module.day04.part2 +# }