File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -64,11 +64,7 @@ private int check(final int cycles, final int x) {
64
64
}
65
65
66
66
private char draw (final int cycles , final int x ) {
67
- if (Range .rangeClosed (x - 1 , x + 1 , 1 ).contains (cycles % 40 )) {
68
- return FILL ;
69
- } else {
70
- return EMPTY ;
71
- }
67
+ return Math .abs (x - cycles % 40 ) <= 1 ? FILL : EMPTY ;
72
68
}
73
69
74
70
private List <String > getPixels () {
@@ -89,7 +85,9 @@ public Integer solvePart1() {
89
85
90
86
@ Override
91
87
public String solvePart2 () {
92
- return OCR .convert6 (Grid .from (getPixels ()), FILL , EMPTY );
88
+ final List <String > pixels = getPixels ();
89
+ pixels .forEach (this ::log );
90
+ return OCR .convert6 (Grid .from (pixels ), FILL , EMPTY );
93
91
}
94
92
95
93
public static void main (final String [] args ) throws Exception {
@@ -107,7 +105,7 @@ public static void main(final String[] args) throws Exception {
107
105
final List <String > inputData = puzzle .getInputData ();
108
106
puzzle .check (
109
107
() -> lap ("Part 1" , AoC2022_10 .create (inputData )::solvePart1 ),
110
- () -> lap ("Part 2" , AoC2022_10 .create (inputData )::solvePart2 )
108
+ () -> lap ("Part 2" , AoC2022_10 .createDebug (inputData )::solvePart2 )
111
109
);
112
110
}
113
111
You can’t perform that action at this time.
0 commit comments