File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed
year2022/src/main/java/dev/linl33/adventofcode/year2022 Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -64,11 +64,7 @@ public Integer part1(@NotNull BufferedReader reader) {
64
64
if (curr > max ) {
65
65
max = curr ;
66
66
maxY = y ;
67
-
68
- if (!visible [x + y * cols ]) {
69
- visible [x + y * cols ] = true ;
70
- visibleTrees ++;
71
- }
67
+ visibleTrees += visible [x + y * cols ] ? 0 : 1 ;
72
68
}
73
69
}
74
70
@@ -78,10 +74,7 @@ public Integer part1(@NotNull BufferedReader reader) {
78
74
var curr = input [y ].charAt (x );
79
75
if (curr > max ) {
80
76
max = curr ;
81
- if (!visible [x + y * cols ]) {
82
- visible [x + y * cols ] = true ;
83
- visibleTrees ++;
84
- }
77
+ visibleTrees += visible [x + y * cols ] ? 0 : 1 ;
85
78
}
86
79
}
87
80
}
@@ -129,7 +122,7 @@ public Integer part2(@NotNull BufferedReader reader) {
129
122
// look left
130
123
score *= treeX - backRef [treeX ];
131
124
132
- var maxPotential = ((( rows - 1 ) / 2 ) * ((rows - 1 ) - ( rows - 1 ) / 2 ) ) * score ;
125
+ var maxPotential = (treeY - colBackRef [ colBackRefPointer ]) * ((rows - 1 ) - treeY ) * score ;
133
126
if (maxPotential <= max ) {
134
127
skippedColumns [treeY ] = true ;
135
128
continue ;
You can’t perform that action at this time.
0 commit comments