package main import ( "bufio" "fmt" "os" ) type coord struct { x,y,nb_neighbors int } func update_neighbors(positions* []*coord, i,j int) int{ nbn := 0 for _, paper_roll := range *positions { switch(paper_roll.x){ case i: switch(paper_roll.y){ case j-1, j+1: nbn++ paper_roll.nb_neighbors++ } case i-1, i+1: switch(paper_roll.y){ case j-1,j,j+1: nbn++ paper_roll.nb_neighbors++ } } } return nbn } func main() { fmt.Println("Advent of Code 2025 - Day 4 - Part 1") f,_ := os.Open("4/input") defer f.Close() var positions []*coord scanner := bufio.NewScanner(f) line_num := 0 res := 0 for scanner.Scan() { line := scanner.Text() for i:= 0; i < len(line); i++{ if line[i] == '@'{ nbn := update_neighbors(&positions,line_num,i) positions = append(positions, &coord{line_num,i,nbn}) } } line_num++ } for _, paper_roll := range positions { if paper_roll.nb_neighbors < 4 {res ++} } fmt.Println(res) }