Skip to content

Commit

Permalink
Small fixes and touch ups
Browse files Browse the repository at this point in the history
  • Loading branch information
cjavad committed Dec 8, 2022
1 parent 3d9e1e5 commit d0992cf
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions 08/day8.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import (
)

func main() {
part1()
}

func part1() {
tree_map := parse_tree_map(utils.ReadInput("input.test.txt"))
tree_map := parse_tree_map(utils.ReadInput("input.txt"))
score_map := make([][]int, len(tree_map))
for i := range score_map {
score_map[i] = make([]int, len(tree_map[i]))
Expand Down Expand Up @@ -80,17 +76,6 @@ func part1() {
fmt.Printf("Part 2: %d\n", max_score)
}

func directional_tree_map(arr [][]int) [][][]bool {
visible := make([][][]bool, len(arr))
for i := range visible {
visible[i] = make([][]bool, len(arr[i]))
for j := range visible[i] {
visible[i][j] = is_visible(arr, i, j)
}
}
return visible
}

func parse_tree_map(input []string) [][]int {
arr := make([][]int, len(input))
for i, line := range input {
Expand All @@ -102,6 +87,21 @@ func parse_tree_map(input []string) [][]int {
return arr
}

/*
Unused function for boolean approach, potentially faster but you cannot extract score after processing
*/

func directional_tree_map(arr [][]int) [][][]bool {
visible := make([][][]bool, len(arr))
for i := range visible {
visible[i] = make([][]bool, len(arr[i]))
for j := range visible[i] {
visible[i][j] = is_visible(arr, i, j)
}
}
return visible
}

// Top, Left, Right, Bottom
func is_visible(arr [][]int, i, j int) []bool {
height := arr[i][j]
Expand Down

0 comments on commit d0992cf

Please sign in to comment.