Skip to content

Commit 6941f2b

Browse files
committed
Rely more on type coercion
1 parent dc92b65 commit 6941f2b

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

2024/bonus/day01/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ locals {
66
cleaned_input = replace(var.input, "/ +/", " ")
77
lines = split("\n", trim(local.cleaned_input, "\n"))
88
lines_split = [for line in local.lines : split(" ", line)]
9-
left = [for line in local.lines_split : parseint(line[0], 10)]
10-
right = [for line in local.lines_split : parseint(line[1], 10)]
9+
left = [for line in local.lines_split : tonumber(line[0])]
10+
right = [for line in local.lines_split : tonumber(line[1])]
1111

1212
left_sorted = sort(local.left)
1313
right_sorted = sort(local.right)

2024/bonus/day02/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ variable "input" {
33
}
44

55
locals {
6-
reports = [for line in split("\n", trim(var.input, "\n")) : [for num in split(" ", line) : parseint(num, 10)]]
6+
reports = [for line in split("\n", trim(var.input, "\n")) : split(" ", line)]
77
}
88

99
module "part1_valid" {

2024/bonus/day13/main.tf

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
variable "input" {
2-
type = string
3-
default = <<-EOT
4-
Button A: X+94, Y+34
5-
Button B: X+22, Y+67
6-
Prize: X=8400, Y=5400
7-
8-
Button A: X+26, Y+66
9-
Button B: X+67, Y+21
10-
Prize: X=12748, Y=12176
11-
12-
Button A: X+17, Y+86
13-
Button B: X+84, Y+37
14-
Prize: X=7870, Y=6450
15-
16-
Button A: X+69, Y+23
17-
Button B: X+27, Y+71
18-
Prize: X=18641, Y=10279
19-
EOT
2+
type = string
203
}
214

225
locals {
@@ -35,7 +18,7 @@ module "solve2" {
3518
source = "./solve"
3619
machines = [
3720
for machine in local.machines :
38-
[machine[0], machine[1], machine[2], machine[3], 10000000000000 + tonumber(machine[4]), 10000000000000 + tonumber(machine[5])]
21+
[machine[0], machine[1], machine[2], machine[3], 10000000000000 + machine[4], 10000000000000 + machine[5]]
3922
]
4023
}
4124

0 commit comments

Comments
 (0)