2024 day 12 Complete!

This commit is contained in:
Brian Buller 2024-12-12 08:46:54 -06:00
parent 439412bac1
commit 7c4f208bb1
8 changed files with 348 additions and 0 deletions

140
2024/day12/input Normal file
View File

@ -0,0 +1,140 @@
IIXIIIDMMMMMMMMMMMMMMMMMMHHHHHHHHRRRRRRRRRRHOHHHHHMMMMMMMMJMYMLLLLLLLLLLQQQQFFFFEEEEEEEEEEEEENNNNNNNNNNNNIIIIIIIIHIFFFFFFFFFJJJJJJJJJJJJJPJB
IIIIIIIMMMMMMMMMMMMMMMMMHHHHHHHHRRRRRRRRRRRHHHHHHMMMMMMMMMMMMMMLLLLLLLLLFFFFFFFFFEEEEEEEEEEEENNPPNNNNNNNNIIIIIIIIIIFFFFFFFFFFJJJJJJJJJJJJJJJ
IIIIIIIIMMMMMMMMMMMMMMMMDHHHHHHHHRRRRRRRRRRHHHHHMMMUMMMMMMMMMMMLLLLLLLLLFFFFFFFFFEEEEEEEEEEEEEPPPENNNNNNNIIIIIIIIIIFFFFFFFFFWWWJJJJJJJJJJJJJ
IIIIIIIIMMMMMMMMMMMMMQMQHHHHHHHHHRRRRRRRRHHHHHHHEMMMMMMMMMMMMMMLLLLLLLLLKFFFFFFFFFFEEFEEEEEEEEEPPEEEEENNNIIIIIIIIIIFFFFFFFFFWJJJJJJJJJJJJJJJ
IIIIIIIIMMMMMMMMMMMMMQQQHHHHHHHHHHHRRRRHHTHHHHHHEMMMMMMMMMMMMLLLLLLLLFFFFFFFFFFFFFFFFFFEEEEEEPPPPEEEEEEEIIIIIIIIIIIFFFFFFFFFWWJJJJJJJJJJJJJJ
IIIIIIIIIMMMMMMMMLMMMMQQQHHHHHHHRHHRRRHHHHHHHHHHMMMMMMMMMMMMMLLLLLLLLFFFFFFFFFFFFFFFFFFEEEEEEPCCPPEEEEEEEIIIIIIIIIIIFFFFFFFFWWJJJJJJJJJJJJJJ
IIIIIIIIMMMMMMMMMMQMMQQQQHHHHHHRRRRRRHHHHHHHHHHMMMMMMMMMMMM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OOOOOOOOOOOGGGGGGGGGGFFFFFFFFFXXXXXXXVVVVVVVAAAAAAAAAAAAAAAAYYYYYYYYYYYYYYYY
XXXXXXXXDDDDDDDDDDDXDDJJJJSSBBBBBBBTTTTTTTTTXXXXXXXMMMMMMMMMMMMOOOOOOOOOOOOOOOOOGGGFFFFFFFFFFXXXXXXQXXVVVVVVAAAAAAAAAAAAAAAAAYYYYYYYYYYYYYYY

162
2024/day12/main.go Normal file
View File

@ -0,0 +1,162 @@
package main
import (
"fmt"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
func main() {
inp := h.StdinToCoordMap()
part1(inp)
fmt.Println("")
part2(inp)
}
func part1(inp h.CoordByteMap) {
fmt.Println("# Part 1")
var total int
trackedPlots := make(map[h.Coordinate]bool)
for y := inp.TLY; y <= inp.BRY; y++ {
for x := inp.TLX; x <= inp.BRX; x++ {
c := h.Coordinate{X: x, Y: y}
if trackedPlots[c] {
continue
}
plant := inp.Get(c)
region := findRegion(inp, c, make(map[h.Coordinate]bool))
area := len(region)
var perimeter int
for k := range region {
trackedPlots[k] = true
for _, chk := range []h.Coordinate{k.North(), k.East(), k.South(), k.West()} {
if inp.Get(chk) != plant {
perimeter++
}
}
}
total = total + (area * perimeter)
}
}
fmt.Println("Total Price:", total)
}
func part2(inp h.CoordByteMap) {
fmt.Println("# Part 2")
var total int
trackedPlots := make(map[h.Coordinate]bool)
for y := inp.TLY; y <= inp.BRY; y++ {
for x := inp.TLX; x <= inp.BRX; x++ {
c := h.Coordinate{X: x, Y: y}
if trackedPlots[c] {
continue
}
region := findRegion(inp, c, make(map[h.Coordinate]bool))
area := len(region)
for k := range region {
trackedPlots[k] = true
}
sides := findSides(region)
total = total + (area * sides)
}
}
fmt.Println("Total Price:", total)
}
func findRegion(inp h.CoordByteMap, start h.Coordinate, checked map[h.Coordinate]bool) map[h.Coordinate]bool {
ret := make(map[h.Coordinate]bool)
bt := inp.Get(start)
ret[start] = true
for _, chk := range []h.Coordinate{start.North(), start.East(), start.South(), start.West()} {
if checked[chk] {
continue
}
if inp.Get(chk) == bt {
checked[chk] = true
ret[chk] = true
for k := range findRegion(inp, chk, checked) {
ret[k] = true
}
}
}
return ret
}
var (
N = h.Coordinate{X: 0, Y: -1}
NE = h.Coordinate{X: 1, Y: -1}
E = h.Coordinate{X: 1, Y: 0}
SE = h.Coordinate{X: 1, Y: 1}
S = h.Coordinate{X: 0, Y: 1}
SW = h.Coordinate{X: -1, Y: 1}
W = h.Coordinate{X: -1, Y: 0}
NW = h.Coordinate{X: -1, Y: -1}
)
func findSides(region map[h.Coordinate]bool) int {
var sides int
for chk := range region {
sides = sides + checkForExteriorCorner(chk, region)
sides = sides + checkForInteriorCorner(chk, region)
}
return sides
}
// checkForExteriorCorner returns how many exterior corners 'chk' is a part of
func checkForExteriorCorner(chk h.Coordinate, region map[h.Coordinate]bool) int {
var ret int
// Check orthoganal neighbor pairs (N/E, E/S, S/W, W/N) for an exterior corner
if checkDiff(chk, N, region) {
if checkDiff(chk, E, region) {
ret++
}
if checkDiff(chk, W, region) {
ret++
}
}
if checkDiff(chk, S, region) {
if checkDiff(chk, E, region) {
ret++
}
if checkDiff(chk, W, region) {
ret++
}
}
return ret
}
// checkForInteriorCorner returns how many interior corners 'chk' is a part of
func checkForInteriorCorner(chk h.Coordinate, region map[h.Coordinate]bool) int {
var ret int
// Check for interior corner (N/E != NE, E/S != SE, S/W != SW, W/N != NW)
if checkDiff(chk, NE, region) {
if checkSame(chk, N, region) && checkSame(chk, E, region) {
ret++
}
}
if checkDiff(chk, SE, region) {
if checkSame(chk, S, region) && checkSame(chk, E, region) {
ret++
}
}
if checkDiff(chk, SW, region) {
if checkSame(chk, S, region) && checkSame(chk, W, region) {
ret++
}
}
if checkDiff(chk, NW, region) {
if checkSame(chk, N, region) && checkSame(chk, W, region) {
ret++
}
}
return ret
}
func checkDiff(chk, dir h.Coordinate, region map[h.Coordinate]bool) bool {
return !checkSame(chk, dir, region)
}
func checkSame(chk, dir h.Coordinate, region map[h.Coordinate]bool) bool {
_, ok := region[chk.Add(dir)]
return ok
}

4
2024/day12/testinput Normal file
View File

@ -0,0 +1,4 @@
AAAA
BBCD
BBCC
EEEC

5
2024/day12/testinput2 Normal file
View File

@ -0,0 +1,5 @@
OOOOO
OXOXO
OOOOO
OXOXO
OOOOO

10
2024/day12/testinput3 Normal file
View File

@ -0,0 +1,10 @@
RRRRIICCFF
RRRRIICCCF
VVRRRCCFFF
VVRCCCJFFF
VVVVCJJCFE
VVIVCCJJEE
VVIIICJJEE
MIIIIIJJEE
MIIISIJEEE
MMMISSJEEE

5
2024/day12/testinput4 Normal file
View File

@ -0,0 +1,5 @@
EEEEE
EXXXX
EEEEE
EXXXX
EEEEE

6
2024/day12/testinput5 Normal file
View File

@ -0,0 +1,6 @@
AAAAAA
AAABBA
AAABBA
ABBAAA
ABBAAA
AAAAAA

View File

@ -249,6 +249,22 @@ func (m *CoordByteMap) InsertColAfter(col int, fill byte) {
}
}
// FindAllUnique searches the whole map and returns a slice of all unique bytes
func (m *CoordByteMap) FindAllUnique() []byte {
var ret []byte
track := make(map[byte]bool)
for y := m.TLY; y <= m.BRY; y++ {
for x := m.TLX; x <= m.BRX; x++ {
c := Coordinate{X: x, Y: y}
if !track[m.Get(c)] {
ret = append(ret, m.Get(c))
track[m.Get(c)] = true
}
}
}
return ret
}
// FindFirst searches left to right, top to bottom for the first
// instance of b.
func (m *CoordByteMap) FindFirst(b byte) (Coordinate, error) {