mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Optimize day 4 enough to run
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
# }
|
||||
|
||||
Reference in New Issue
Block a user