aoc2023/day-5/data.go

23 lines
377 B
Go
Raw Normal View History

2023-12-06 04:01:17 +00:00
package main
2024-01-01 11:32:43 +00:00
type data struct {
2023-12-06 04:01:17 +00:00
dest int
source int
offset int
}
2024-01-01 11:32:43 +00:00
func newData(nums ...int) data {
return data{dest: nums[0], source: nums[1], offset: nums[2]}
}
2023-12-06 04:01:17 +00:00
2024-01-01 11:32:43 +00:00
func (d data) transform(start, end int) (int, int) {
f := func(x int) int {
return x - d.source + d.dest
}
return f(start), f(end - 1)
2023-12-06 04:01:17 +00:00
}
2024-01-01 11:32:43 +00:00
var dataMap = map[string][]data{}
var identifiers = []string{}