Prepare for other years
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
plugins {
|
||||
id("java-convention")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":utils"))
|
||||
|
||||
annotationProcessor(Libs.Micronaut.processor)
|
||||
|
||||
implementation(Libs.eclipseCollections)
|
||||
|
||||
testImplementation(Libs.Jmh.core)
|
||||
testAnnotationProcessor(Libs.Jmh.processor)
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package be.vandewalleh.aoc;
|
||||
|
||||
import be.vandewalleh.aoc.utils.factory.Days;
|
||||
import be.vandewalleh.aoc.utils.input.Day;
|
||||
import be.vandewalleh.aoc.utils.input.Input;
|
||||
import be.vandewalleh.aoc.utils.input.Lines;
|
||||
|
||||
@Day(1)
|
||||
public class Day01 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
var day = Days.createDay(Day01.class);
|
||||
System.out.println(day.part1());
|
||||
System.out.println(day.part2());
|
||||
}
|
||||
|
||||
private final int[] input;
|
||||
|
||||
public Day01(@Lines Input<int[]> input) {
|
||||
this.input = input.getValue();
|
||||
}
|
||||
|
||||
private int fuel(int mass) {
|
||||
return (mass / 3) - 2;
|
||||
}
|
||||
|
||||
public int part1() {
|
||||
var total = 0;
|
||||
for (var mass : input) {
|
||||
total += fuel(mass);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int part2() {
|
||||
var total = 0;
|
||||
for (var mass : input) {
|
||||
int fuel = fuel(mass);
|
||||
int subTotal = fuel;
|
||||
while (true) {
|
||||
fuel = fuel(fuel);
|
||||
if (fuel <= 0) break;
|
||||
subTotal += fuel;
|
||||
}
|
||||
total += subTotal;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
132791
|
||||
78272
|
||||
114679
|
||||
60602
|
||||
59038
|
||||
69747
|
||||
61672
|
||||
147972
|
||||
92618
|
||||
70186
|
||||
125826
|
||||
61803
|
||||
78112
|
||||
124864
|
||||
58441
|
||||
113062
|
||||
105389
|
||||
125983
|
||||
90716
|
||||
75544
|
||||
148451
|
||||
73739
|
||||
127762
|
||||
146660
|
||||
128747
|
||||
148129
|
||||
138635
|
||||
80095
|
||||
60241
|
||||
145455
|
||||
98730
|
||||
59139
|
||||
146828
|
||||
113550
|
||||
91682
|
||||
107415
|
||||
129207
|
||||
147635
|
||||
104583
|
||||
102245
|
||||
73446
|
||||
148657
|
||||
96364
|
||||
52033
|
||||
69964
|
||||
63609
|
||||
98207
|
||||
73401
|
||||
65511
|
||||
115034
|
||||
126179
|
||||
96664
|
||||
85394
|
||||
128472
|
||||
79017
|
||||
93222
|
||||
55267
|
||||
102446
|
||||
133150
|
||||
148985
|
||||
95325
|
||||
57713
|
||||
77370
|
||||
60879
|
||||
111977
|
||||
99362
|
||||
91581
|
||||
55201
|
||||
137670
|
||||
127159
|
||||
128324
|
||||
77217
|
||||
86378
|
||||
112847
|
||||
108265
|
||||
80355
|
||||
75650
|
||||
106222
|
||||
67793
|
||||
113891
|
||||
74508
|
||||
139463
|
||||
69972
|
||||
122753
|
||||
135854
|
||||
127770
|
||||
101085
|
||||
98304
|
||||
61451
|
||||
146719
|
||||
61225
|
||||
60468
|
||||
83613
|
||||
137436
|
||||
126303
|
||||
78759
|
||||
70081
|
||||
110671
|
||||
113234
|
||||
111563
|
||||
Reference in New Issue
Block a user