Files
aoc2025/day05/Notes.md
2025-12-07 00:05:24 +01:00

855 B

Day 5: Notes

Star 1

  • for each ID, for each interval, check if ID is in interval
  • could be parallelized
    • goroutine for each ID - sounds okay
    • also goroutines for intervals - overkill?

Interval:

type Interval struct {
	From int
	To   int
}

func (i *Interval) In(val int) bool {
	return i.From <= val && val <= i.To
}

Star 2

  • intervals need to be merged
  • to do that efficiently, they need to be sorted
  • then, a sequence of intervals can be merged:
100596811663215  -  100867276610455
100596811663215  -  101195447377813
100596811663215  -  101195447397536

100596811663215  -  101195447397536
  • start of first and end of last
  • iterate over list of intervals
  • find furthest matching start
  • copy new merged interval into separate list

Attempts

  • 323939472567605: too low
  • 422408896659291: too high