mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 12:50:32 +01:00
Rely more on type coercion
This commit is contained in:
@@ -6,8 +6,8 @@ locals {
|
||||
cleaned_input = replace(var.input, "/ +/", " ")
|
||||
lines = split("\n", trim(local.cleaned_input, "\n"))
|
||||
lines_split = [for line in local.lines : split(" ", line)]
|
||||
left = [for line in local.lines_split : parseint(line[0], 10)]
|
||||
right = [for line in local.lines_split : parseint(line[1], 10)]
|
||||
left = [for line in local.lines_split : tonumber(line[0])]
|
||||
right = [for line in local.lines_split : tonumber(line[1])]
|
||||
|
||||
left_sorted = sort(local.left)
|
||||
right_sorted = sort(local.right)
|
||||
|
||||
@@ -3,7 +3,7 @@ variable "input" {
|
||||
}
|
||||
|
||||
locals {
|
||||
reports = [for line in split("\n", trim(var.input, "\n")) : [for num in split(" ", line) : parseint(num, 10)]]
|
||||
reports = [for line in split("\n", trim(var.input, "\n")) : split(" ", line)]
|
||||
}
|
||||
|
||||
module "part1_valid" {
|
||||
|
||||
@@ -1,22 +1,5 @@
|
||||
variable "input" {
|
||||
type = string
|
||||
default = <<-EOT
|
||||
Button A: X+94, Y+34
|
||||
Button B: X+22, Y+67
|
||||
Prize: X=8400, Y=5400
|
||||
|
||||
Button A: X+26, Y+66
|
||||
Button B: X+67, Y+21
|
||||
Prize: X=12748, Y=12176
|
||||
|
||||
Button A: X+17, Y+86
|
||||
Button B: X+84, Y+37
|
||||
Prize: X=7870, Y=6450
|
||||
|
||||
Button A: X+69, Y+23
|
||||
Button B: X+27, Y+71
|
||||
Prize: X=18641, Y=10279
|
||||
EOT
|
||||
type = string
|
||||
}
|
||||
|
||||
locals {
|
||||
@@ -35,7 +18,7 @@ module "solve2" {
|
||||
source = "./solve"
|
||||
machines = [
|
||||
for machine in local.machines :
|
||||
[machine[0], machine[1], machine[2], machine[3], 10000000000000 + tonumber(machine[4]), 10000000000000 + tonumber(machine[5])]
|
||||
[machine[0], machine[1], machine[2], machine[3], 10000000000000 + machine[4], 10000000000000 + machine[5]]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user