File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,34 @@ public function solve_part_1(): string
28
28
29
29
public function solve_part_2 (): string
30
30
{
31
- return "TODO " ;
31
+ $ width = 40 ;
32
+ $ height = 6 ;
33
+ $ changes = $ this ->getRegisterChanges ();
34
+ $ screen = array_fill (0 , $ width *$ height , ' ' );
35
+ $ x = $ cycle = 1 ;
36
+ foreach ($ changes as $ change ) {
37
+ if ($ this ->isInRange ( ($ cycle % $ width )-1 , $ x -1 , $ x +1 )) {
38
+ $ screen [$ cycle -1 ] = '▓ ' ;
39
+ }
40
+ $ x += $ change ;
41
+ $ cycle += 1 ;
42
+ }
43
+ echo "\n" ;
44
+ for ($ y = 0 ; $ y < $ height ; $ y += 1 ) {
45
+ $ line = implode ('' , array_slice ($ screen , $ y *$ width , $ width -1 ));
46
+ echo " {$ y } {$ line }\n" ;
47
+ }
48
+ echo " " ;
49
+ for ($ x = 0 ; $ x < $ width ; $ x += 1 ) {
50
+ echo $ x % 10 ;
51
+ }
52
+ echo "\n\n" ;
53
+ return "TODO: OCR " ;
54
+ }
55
+
56
+ protected function isInRange ($ x , $ start , $ end )
57
+ {
58
+ return $ x >= $ start && $ x <= $ end ;
32
59
}
33
60
34
61
protected function getRegisterChanges ()
You can’t perform that action at this time.
0 commit comments