|
|
@@ -0,0 +1,44 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ "bufio"
|
|
|
+ "fmt"
|
|
|
+ "math"
|
|
|
+ "os"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+func main() {
|
|
|
+ fmt.Println("Advent of Code 2025 - Day 9 - Part 1")
|
|
|
+ f,_:= os.Open("9/input")
|
|
|
+ defer f.Close()
|
|
|
+ scanner:=bufio.NewScanner(f)
|
|
|
+
|
|
|
+ var red_walls [][]int
|
|
|
+ for scanner.Scan(){
|
|
|
+ line:= scanner.Text()
|
|
|
+ line_sp := strings.Split(line, ",")
|
|
|
+ x,_:= strconv.Atoi(line_sp[0])
|
|
|
+ y,_:= strconv.Atoi(line_sp[1])
|
|
|
+ red_walls = append(red_walls, []int{x,y})
|
|
|
+ }
|
|
|
+
|
|
|
+ res := 0
|
|
|
+ for i:= range red_walls {
|
|
|
+ w1:= red_walls[i]
|
|
|
+ for j:= i+1; j < len(red_walls); j++{
|
|
|
+ w2:= red_walls[j]
|
|
|
+ area := calculate_area(w1,w2)
|
|
|
+ if area > res {
|
|
|
+ res = area
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fmt.Println(res)
|
|
|
+}
|
|
|
+
|
|
|
+func calculate_area(w1,w2 []int) int{
|
|
|
+ dx, dy := int(math.Abs(float64(w1[0]-w2[0]))), int(math.Abs(float64(w1[1]-w2[1])))
|
|
|
+ return (dx+1) * (dy+1)
|
|
|
+}
|