71 lines
1.0 KiB
Go
71 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
"strings"
|
|
|
|
"git.z1glr.de/advent-of-code-2025/pkg/aoc"
|
|
)
|
|
|
|
type Point struct {
|
|
X, Y int
|
|
}
|
|
|
|
type Rect struct {
|
|
P1, P2 *Point
|
|
}
|
|
|
|
func (r Rect) Area() float64 {
|
|
return math.Abs(float64((r.P1.X - r.P2.X + 1) * (r.P1.Y - r.P2.Y + 1)))
|
|
}
|
|
|
|
func do(test bool) (int, int) {
|
|
rows := aoc.ReadFileRows(test)
|
|
|
|
points := make([]Point, len(rows))
|
|
|
|
for ii, rr := range rows {
|
|
parts := strings.Split(rr, ",")
|
|
|
|
points[ii] = Point{
|
|
X: aoc.ParseInt(parts[0]),
|
|
Y: aoc.ParseInt(parts[1]),
|
|
}
|
|
}
|
|
|
|
largestArea := 0
|
|
largestArea2 := 0
|
|
|
|
rects := make([]*Rect, len(points)*(len(points)+1)/2)
|
|
|
|
for ii := range points {
|
|
for jj := range points[ii+1:] {
|
|
rects[ii+jj+1] = &Rect{
|
|
P1: &points[ii],
|
|
P2: &points[jj+ii+1],
|
|
}
|
|
}
|
|
}
|
|
|
|
for ii := range rects {
|
|
rr := &rects[ii]
|
|
|
|
// iterate all others
|
|
for jj := range rects {
|
|
if jj != ii {
|
|
}
|
|
}
|
|
}
|
|
|
|
fmt.Printf("%9.0f\n", largestArea)
|
|
|
|
return int(largestArea), 0
|
|
}
|
|
|
|
func main() {
|
|
if r1, r2 := do(true); r1 == 50 && r2 == 0 {
|
|
do(false)
|
|
}
|
|
}
|