Solutions for day 10.
This commit is contained in:
parent
e47b6c4a45
commit
28998c5d14
4 changed files with 67 additions and 18 deletions
|
@ -1,5 +1,11 @@
|
|||
// Unused solution: yes, this is a SECOND failed solution. Left here as a testament
|
||||
// to... something. The actual solution uses CalculateRange from point.go
|
||||
package day10
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
// GroupPoints creates groups of points, then sorts them and returns the sorted list
|
||||
// A 'group' is a series of points that are adjacent to each other.
|
||||
// If this function finds any non-adjacent points, it returns nil.
|
||||
|
@ -36,7 +42,12 @@ func GroupPoints(points []*Point) [][]*Point {
|
|||
groups = append(groups, group)
|
||||
}
|
||||
|
||||
// TODO: sort the groups
|
||||
// sort the groups
|
||||
sort.Slice(groups[:], func(i, j int) bool {
|
||||
xMin1, _, _, _ := findBounds(groups[i])
|
||||
xMin2, _, _, _ := findBounds(groups[j])
|
||||
return xMin1 < xMin2
|
||||
})
|
||||
|
||||
return groups
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue