@@ -43,12 +43,11 @@ public static AoC2024_15 createDebug() {
4343 @ Override
4444 protected Input parseInput (final List <String > inputs ) {
4545 final List <List <String >> blocks = StringOps .toBlocks (inputs );
46- final Grid grid = new Grid (CharGrid .from (blocks .get (0 )));
4746 final List <Direction > dirs = Utils .asCharacterStream (
4847 blocks .get (1 ).stream ().collect (joining ()))
4948 .map (Direction ::fromChar )
5049 .toList ();
51- return new Input (grid , dirs );
50+ return new Input (new GridSupplier ( blocks . get ( 0 )) , dirs );
5251 }
5352
5453 private int solve (
@@ -192,7 +191,7 @@ private interface GetToMove {
192191 List <Cell > getToMove (CharGrid grid , Cell robot , Direction dir );
193192 }
194193
195- record Grid ( CharGrid gridIn ) {
194+ record GridSupplier ( List < String > gridIn ) {
196195 private static final Map <Character , char []> SCALE_UP = Map .of (
197196 FLOOR , new char [] { FLOOR , FLOOR },
198197 WALL , new char [] { WALL , WALL },
@@ -201,23 +200,24 @@ record Grid(CharGrid gridIn) {
201200 );
202201
203202 public CharGrid getGrid () {
204- return this .gridIn . copy ( );
203+ return CharGrid . from ( this .gridIn );
205204 }
206205
207206 public CharGrid getWideGrid () {
208- final char [][] chars = new char [this .gridIn .getHeight ()][];
209- for (final int r : range (this .gridIn .getHeight ())) {
210- final char [] row = new char [2 * this .gridIn .getWidth ()];
211- for (final int c : range (this .gridIn .getWidth ())) {
212- final char ch = this .gridIn .getValue (Cell .at (r , c ));
213- row [2 * c ] = SCALE_UP .get (ch )[0 ];
214- row [2 * c + 1 ] = SCALE_UP .get (ch )[1 ];
207+ final char [][] chars = new char [this .gridIn .size ()][];
208+ for (final int r : range (this .gridIn .size ())) {
209+ final String line = this .gridIn .get (r );
210+ final char [] row = new char [2 * line .length ()];
211+ for (final int c : range (line .length ())) {
212+ final char [] s = SCALE_UP .get (line .charAt (c ));
213+ row [2 * c ] = s [0 ];
214+ row [2 * c + 1 ] = s [1 ];
215215 }
216216 chars [r ] = row ;
217217 }
218218 return new CharGrid (chars );
219219 }
220220 }
221221
222- record Input (Grid grid , List <Direction > dirs ) {}
222+ record Input (GridSupplier grid , List <Direction > dirs ) {}
223223}
0 commit comments