day10, part2

This commit is contained in:
efim 2023-12-10 17:49:26 +00:00
parent 69cf6b9aaf
commit 37ee3e99da
1 changed files with 18 additions and 6 deletions

View File

@ -12,7 +12,7 @@ import (
func Run() int {
fmt.Println("hello day 10")
// filename := "day10/example2noisy"
filename := "day10/example6"
filename := "day10/input"
fieldMap := Read(filename)
fmt.Println(fieldMap.BeastCoord)
// fmt.Println(fieldMap.String())
@ -24,13 +24,13 @@ func Run() int {
// fieldMap.checkDirectionFromBeast(Coord{1,2})
beastNeighborCoords := fieldMap.Cells[fieldMap.BeastCoord].Neighbords
len := 0
// len := 0
for _, coord := range beastNeighborCoords {
log.Printf("checking neighbor %v\n", coord)
isCycle, curLen := fieldMap.checkDirectionFromBeast(coord)
isCycle, _ := fieldMap.checkDirectionFromBeast(coord)
if isCycle {
log.Printf("found cycle through %v\n", coord)
len = curLen
// len = curLen
break
}
}
@ -45,14 +45,26 @@ func Run() int {
// TODO Hardcode change S to correct Title
fixedBeast := fieldMap.Cells[fieldMap.BeastCoord]
fixedBeast.Tile = '7'
// fmt.Printf("figuring out how to fix beast:\n%+v", fixedBeast)
fixedBeast.Tile = '|'
fieldMap.Cells[fieldMap.BeastCoord] = fixedBeast
fieldMap.countIntersectionsTopDown()
// fieldMap.initialMarkOuter()
fmt.Println("after marking closest Outer:")
fmt.Println(fieldMap.String())
return (len / 2) + (len % 2)
// now let's coiunt the inner
result := 0
for _, cell := range fieldMap.Cells {
if !cell.IsOnMainPath && !cell.IsOuter {
result += 1
}
}
// prevResult := (len / 2) + (len % 2)
return result
}
// so do i work with just [][]rune ?