@@ -103,27 +103,27 @@ enum Mode {
103103 BY_COLUMNS
104104 }
105105
106- record WorkSheet (List <String > strings ) {
106+ record WorkSheet (CharGrid grid , List <Problem . Operation > ops ) {
107107
108108 public static WorkSheet fromInput (final List <String > inputs ) {
109- return new WorkSheet (inputs );
110- }
111-
112- public Set <Problem > getProblems (final Mode mode ) {
113- final Set <Problem > problems = new HashSet <>();
114109 final CharGrid grid =
115110 CharGrid .from (
116- range (this . strings .size () - 1 ).stream ()
117- .map (i -> this . strings .get (i ) + " " )
111+ range (inputs .size () - 1 ).stream ()
112+ .map (i -> inputs .get (i ) + " " )
118113 .toList ());
119114 final List <Problem .Operation > ops =
120- Arrays .stream (this . strings .getLast ().strip ().split ("\\ s+" ))
115+ Arrays .stream (inputs .getLast ().strip ().split ("\\ s+" ))
121116 .map (Problem .Operation ::fromString )
122117 .toList ();
118+ return new WorkSheet (grid , ops );
119+ }
120+
121+ public Set <Problem > getProblems (final Mode mode ) {
122+ final Set <Problem > problems = new HashSet <>();
123123 final List <String > nums = new ArrayList <>();
124124 int j = 0 ;
125- for (int col = 0 ; col < grid .getWidth (); col ++) {
126- final String s = grid .getColumnAsString (col );
125+ for (int col = 0 ; col < this . grid .getWidth (); col ++) {
126+ final String s = this . grid .getColumnAsString (col );
127127 if (s .isBlank ()) {
128128 final Stream <String > rows =
129129 switch (mode ) {
@@ -133,7 +133,7 @@ public Set<Problem> getProblems(final Mode mode) {
133133 problems .add (
134134 new Problem (
135135 rows .mapToLong (row -> Long .parseLong (row .strip ())).toArray (),
136- ops .get (j )));
136+ this . ops .get (j )));
137137 nums .clear ();
138138 j ++;
139139 } else {
0 commit comments