File tree Expand file tree Collapse file tree 4 files changed +26
-6
lines changed
src/main/java/de/havox_design/aoc2015/day23 Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ plugins {
44
55// project meta data
66group ' de.havox_design.aoc2015'
7- version ' 0.22.4 '
7+ version ' 0.22.5 '
88
99// Switch to gradle "all" distribution.
1010wrapper {
Original file line number Diff line number Diff line change 2929inc a
3030```
3131What is ** the value in register ` b ` ** when the program in your puzzle input is finished executing?
32+
33+ # Part Two
34+ The unknown benefactor is ** very** thankful for releasi-- er, helping little Jane Marie with her computer. Definitely
35+ not to distract you, what is the value in register ` b ` after the program is finished executing if register ` a ` starts
36+ as ` 1 ` instead?
Original file line number Diff line number Diff line change 11package de .havox_design .aoc2015 .day23 ;
22
33public class State {
4+ public State () {
5+ super ();
6+ }
7+
8+ public State (int registerA , int registerB ) {
9+ this ();
10+
11+ this .registerA = registerA ;
12+ this .registerB = registerB ;
13+ }
14+
415 int processCount = 0 ;
516 int registerA = 0 ;
617 int registerB = 0 ;
Original file line number Diff line number Diff line change @@ -28,19 +28,23 @@ public static int solvePart2(String fileName) {
2828 }
2929
3030 public int solvePart1 () {
31+ return processData (0 , 0 );
32+ }
33+
34+ public int solvePart2 () {
35+ return processData (1 , 0 );
36+ }
37+
38+ private int processData (int initialA , int initialB ) {
3139 List <Operation > operations = tokenStream (input , PATTERN , this ::parseOperation ).toList ();
32- State state = new State ();
40+ State state = new State (initialA , initialB );
3341 while (state .processCount < operations .size ()) {
3442 Operation operation = operations .get (state .processCount );
3543 operation .operate (state );
3644 }
3745 return state .registerB ;
3846 }
3947
40- public int solvePart2 () {
41- return 0 ;
42- }
43-
4448 private List <String > readData (String fileName ) {
4549 return DataReader .readData (fileName , MainClass .class );
4650 }
You can’t perform that action at this time.
0 commit comments