Skip to content

Commit

Permalink
Rely more on type coercion
Browse files Browse the repository at this point in the history
  • Loading branch information
bertptrs committed Jan 21, 2025
1 parent dc92b65 commit 6941f2b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
4 changes: 2 additions & 2 deletions 2024/bonus/day01/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion 2024/bonus/day02/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
21 changes: 2 additions & 19 deletions 2024/bonus/day13/main.tf
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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]]
]
}

Expand Down

0 comments on commit 6941f2b

Please sign in to comment.