mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 13:50:32 +01:00
Part 2 and actual testing
This commit is contained in:
@@ -13,8 +13,14 @@ locals {
|
||||
right_sorted = sort(local.right)
|
||||
|
||||
diffs = [for i in range(length(local.left_sorted)): abs(local.left_sorted[i] - local.right_sorted[i])]
|
||||
|
||||
matching = [for left in local.left: sum([for right in local.right: left == right ? left : 0])]
|
||||
}
|
||||
|
||||
output "part1" {
|
||||
value = sum(local.diffs)
|
||||
}
|
||||
|
||||
output "part2" {
|
||||
value = sum(local.matching)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user