File tree Expand file tree Collapse file tree 2 files changed +2
-36
lines changed
2024/src/main/java/me/zodac/advent
common-utils/src/main/java/me/zodac/advent/input Expand file tree Collapse file tree 2 files changed +2
-36
lines changed Original file line number Diff line number Diff line change @@ -87,8 +87,9 @@ public static long calculateMaximumPossibleBananas(final Collection<Integer> ini
87
87
88
88
final Collection <Long > existingDiffs = new HashSet <>();
89
89
90
+ final int numberOfPrices = prices .size ();
90
91
long runningDiff = 0L ;
91
- for (int i = 1 ; i < prices . size () ; i ++) {
92
+ for (int i = 1 ; i < numberOfPrices ; i ++) {
92
93
// Diff calculated based on following logic, gives a concise value for the diff that can be used for comparisons
93
94
// https://github.com/p-kovacs/advent-of-code-2024/blob/master/src/main/java/com/github/pkovacs/aoc/y2024/Day22.java#L33
94
95
runningDiff = (runningDiff % DIFF_RADIX_CUBED ) * DIFF_RADIX + (prices .get (i ) - prices .get (i - 1 ) + DIFF_RADIX_OFFSET );
@@ -169,5 +170,4 @@ private static long mix(final long first, final long second) {
169
170
private static long prune (final long input ) {
170
171
return input % PRUNE_CONSTANT ;
171
172
}
172
-
173
173
}
Original file line number Diff line number Diff line change @@ -365,40 +365,6 @@ private Grouper(final Stream<? extends T> stream) {
365
365
this .stream = stream ;
366
366
}
367
367
368
- /**
369
- * Groups the {@code stream} of lines into {@link List}s, where each group has a size of {@code sizeOfGroup}.
370
- *
371
- * @param sizeOfGroup the size of the groups
372
- * @return the group of {@link List}s of lines of the output type
373
- */
374
- public List <List <T >> bySize (final int sizeOfGroup ) {
375
- final List <? extends T > list = stream .toList ();
376
- final List <List <T >> groups = new ArrayList <>();
377
- final int sizeOfList = list .size ();
378
- List <T > currentGroup = new ArrayList <>();
379
- currentGroup .add (list .getFirst ());
380
-
381
- for (int i = 1 ; i < sizeOfList ; i ++) {
382
- final T line = list .get (i );
383
-
384
- if (i % sizeOfGroup == 0 ) {
385
- if (!currentGroup .isEmpty ()) {
386
- groups .add (currentGroup );
387
- }
388
- currentGroup = new ArrayList <>();
389
- currentGroup .add (line );
390
- } else {
391
- currentGroup .add (line );
392
- }
393
- }
394
-
395
- // Add last group if not empty
396
- if (!currentGroup .isEmpty ()) {
397
- groups .add (currentGroup );
398
- }
399
- return groups ;
400
- }
401
-
402
368
/**
403
369
* Groups the {@code stream} of lines into {@link List}s, where each group is a split that is delimited when the provided
404
370
* {@link Predicate} is met.
You can’t perform that action at this time.
0 commit comments