From 12b29f445ef12e259398d56de86aa4e0422ce93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borna=20Rajkovi=C4=87?= Date: Thu, 12 Dec 2024 09:16:52 +0100 Subject: [PATCH] Day 12. part 1. --- data.go | 3 + day_12/data.txt | 140 ++++++++++++++++++++++++++++++++++++++++ day_12/example_data.txt | 10 +++ day_12/solution.go | 92 ++++++++++++++++++++++++++ day_12/solution_test.go | 24 +++++++ main.go | 5 ++ 6 files changed, 274 insertions(+) create mode 100644 day_12/data.txt create mode 100644 day_12/example_data.txt create mode 100644 day_12/solution.go create mode 100644 day_12/solution_test.go diff --git a/data.go b/data.go index cd3b73a..a4233d8 100644 --- a/data.go +++ b/data.go @@ -36,3 +36,6 @@ var Day10Data string //go:embed day_11/data.txt var Day11Data string + +//go:embed day_12/data.txt +var Day12Data string diff --git a/day_12/data.txt b/day_12/data.txt new file mode 100644 index 0000000..d858ab7 --- /dev/null +++ b/day_12/data.txt @@ -0,0 +1,140 @@ +KKKKKKKKKKKEEEEEEEEEEWWWWWWWWWWWWUWWUUHSSSHNNNNPVVVVVVVVCRRCCCCCCCYYCSSSSSSSSSSHKHIIIIUDDUUWIIIIIIIIIIIIYUEEDDDYYYYYYYYYYYYYYYYYYYYIIIIIIIJJ +KKKKKKKKKKKEEEEEEEEEHHHWWWWWWWWWWUUUUUHHHHHHHPPPPPVCVCCVCCCCCCCCCCYCCSSSSSSSSSSHHHHIIIUDDUUUIIIIIIIIIIYYYUEEEEEYYWYYYWWWYYYYYYBBBBBIIIIIIJJJ +KKKKKKKKXXKEEEZZZZZZZHHWWWWZZZWCCUUUUUHHHHHHHPPPPPVCCCCCCCCCCCCCCCCCCSSSSSSSHHHHHHHIUUUUUUUIIIIIIIIIIIYYYUEEEEEYYWWWWWWWWWWYYYBBBBBBBBJJJJJJ +KKKKKKKKKKKEEEEZZZZZZZZZZZZZZZWCCCHUUUHHHHHHHPPPPPPCCCQQCCCCCCCCCCCCCSSSSSSHHHHHHHXUUUU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RRRRRT +OOOOOOOOCCCCCCCGGGGJJJHHHHHHHHYGGGGGGGGGQQHHHHHXHHHHHHHXYMMJJJJJMMMMMMMMYYYYYHHFFFFFFFFFFFFFFOOOOOOOOOODDRRRRRRRGGGGGGGTTTTWDDDRRRRRRRRRRRRR +OOOOOOOOCCCCCCCGGGGJJHHHHHHGGGGGGGGGGGGGHHHHHHHHHHHHHMMMMMMKJJJJJMMMMMMMYYYYTHHFFFNFFFFFFFFFFUUUOOOOOODDDDRRRRRGGGGGGGGGGGJDDDXJJRRRRRRRRRRR +OOOOOOGOCCCCJJCJJJGJJJHHHHHZGGGGGGGGGGGGGHHHHHHHHHHHHHMMMMMJJMJMMMMMMMMYYTTYTTXXFNNNFFFFFFCFUUUUUUOOOOODDDRRRRRRGGGGGGGGJJJJJJJJRRRRRRRRRRRR +OOOOOOGCCCCJJJJJJJJJJJHHHHHGGGGGGGGGGGGGGGHHHHHHHHHHHHMMMGMMMMMMMMMMMMMTTTTTTTXXFNNFFCFFFHHFFUUUUUOOOOODDRRRRRRRRGGGVVJJJJJJJJJJJJJRRRRRRRRR +OOOOOOGCCJJJJJJJJJJJJJJHHJHGGGGGGGGGGGGGGGHHHHHHHHHHHHMMMMMMMMMMMMMMMMMTTTTTTTXXFNNFFCFFHHHBFUUUUUOOOOOODRRRRRARGGVVVYJJJJJJJJJFJJRRRRRRRRRR \ No newline at end of file diff --git a/day_12/example_data.txt b/day_12/example_data.txt new file mode 100644 index 0000000..0b328f1 --- /dev/null +++ b/day_12/example_data.txt @@ -0,0 +1,10 @@ +RRRRIICCFF +RRRRIICCCF +VVRRRCCFFF +VVRCCCJFFF +VVVVCJJCFE +VVIVCCJJEE +VVIIICJJEE +MIIIIIJJEE +MIIISIJEEE +MMMISSJEEE \ No newline at end of file diff --git a/day_12/solution.go b/day_12/solution.go new file mode 100644 index 0000000..343bbf1 --- /dev/null +++ b/day_12/solution.go @@ -0,0 +1,92 @@ +package day_12 + +import "strings" + +const Empty = '.' + +type Map [][]rune + +type Point struct { + x, y int +} + +type Visited map[Point]bool + +func (m Map) InMap(x, y int) bool { + return x >= 0 && x < len(m[0]) && y >= 0 && y < len(m) +} + +func (m Map) At(x, y int) rune { + if m.InMap(x, y) { + return m[y][x] + } + return Empty +} + +// task:https://adventofcode.com/2024/day/12 +func SolveBasic(input string) int { + farmMap := loadMap(input) + visited := Visited{} + + sum := 0 + + for y, row := range farmMap { + for x, value := range row { + p := Point{x, y} + field := Visited{} + if _, present := visited[p]; !present { + visit(farmMap, field, x, y, value) + area := len(field) + parameter := 0 + for point := range field { + // mark as visited to not visit it more than once + visited[point] = true + + if _, present := field[Point{point.x - 1, point.y}]; !present { + parameter++ + } + if _, present := field[Point{point.x + 1, point.y}]; !present { + parameter++ + } + if _, present := field[Point{point.x, point.y - 1}]; !present { + parameter++ + } + if _, present := field[Point{point.x, point.y + 1}]; !present { + parameter++ + } + } + sum += area * parameter + } + } + } + + return sum +} + +func visit(farmMap Map, field Visited, x int, y int, value rune) { + if _, visited := field[Point{x, y}]; visited { + return + } + if farmMap.At(x, y) == value { + field[Point{x, y}] = true + + visit(farmMap, field, x-1, y, value) + visit(farmMap, field, x+1, y, value) + visit(farmMap, field, x, y-1, value) + visit(farmMap, field, x, y+1, value) + } +} + +// task:https://adventofcode.com/2024/day/12#part2 +func SolveComplex(input string) int { + return 0 +} + +func loadMap(input string) Map { + input = strings.ReplaceAll(input, "\r", "") + topographicMap := Map{} + for _, line := range strings.Split(input, "\n") { + topographicMap = append(topographicMap, []rune(line)) + } + return topographicMap +} diff --git a/day_12/solution_test.go b/day_12/solution_test.go new file mode 100644 index 0000000..53569bd --- /dev/null +++ b/day_12/solution_test.go @@ -0,0 +1,24 @@ +package day_12_test + +import ( + "advent_of_code_2024/day_12" + _ "embed" + "testing" +) + +//go:embed example_data.txt +var ExampleData string + +func TestBasicSolutionExample(t *testing.T) { + result := day_12.SolveBasic(ExampleData) + if result != 1930 { + t.Fatalf("Expected 1930 received %d", result) + } +} + +func TestComplexSolutionExample(t *testing.T) { + result := day_12.SolveComplex(ExampleData) + if result != 2858 { + t.Fatalf("Expected 2858 received %d", result) + } +} diff --git a/main.go b/main.go index 13e55b1..c77fd92 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "advent_of_code_2024/day_09" "advent_of_code_2024/day_10" "advent_of_code_2024/day_11" + "advent_of_code_2024/day_12" _ "embed" "fmt" "os" @@ -65,6 +66,10 @@ func main() { fmt.Printf("Day 11. Basic: %d\n", day_11.SolveBasic(Day11Data)) // case "11-complex": fmt.Printf("Day 11. Complex: %d\n", day_11.SolveComplex(Day11Data)) // + case "12-basic": + fmt.Printf("Day 12. Basic: %d\n", day_12.SolveBasic(Day12Data)) // + case "12-complex": + fmt.Printf("Day 12. Complex: %d\n", day_12.SolveComplex(Day12Data)) // } }