package main import ( "bufio" "fmt" "os" "aoc2022/day08/common" ) func main() { forest := common.Parse(*bufio.NewScanner(os.Stdin)) maxScore := 0 for i := 0; i < len(forest); i++ { for j := 0; j < len(forest[i]); j++ { score := 1 currScore := 0 for k := i - 1; k >= 0; k-- { currScore++ if forest[k][j] >= forest[i][j] { break } } score *= currScore currScore = 0 for k := j - 1; k >= 0; k-- { currScore++ if forest[i][k] >= forest[i][j] { break } } score *= currScore currScore = 0 for k := i + 1; k < len(forest); k++ { currScore++ if forest[k][j] >= forest[i][j] { break } } score *= currScore currScore = 0 for k := j + 1; k < len(forest[i]); k++ { currScore++ if forest[i][k] >= forest[i][j] { break } } score *= currScore if score > maxScore { maxScore = score } } } fmt.Println(maxScore) }