-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay01.java
47 lines (37 loc) · 1.07 KB
/
Day01.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//part 1
package org.thehuglio;
import java.io.File;
import java.util.List;
public class Main {
private static final List<String> data = new Reader(new File("data.txt")).data;
public static void main(String[] args) {
int depth = 10000000;
int tot = 0;
for (String d : data) {
if (Integer.parseInt(d) > depth) {
tot++;
}
depth = Integer.parseInt(d);
}
System.out.println(tot);
}
}
//part 2
package org.thehuglio;
import java.io.File;
import java.util.List;
public class Main {
private static final List<String> data = new Reader(new File("data.txt")).data;
public static void main(String[] args) {
int depth = 10000000;
int tot = 0;
for (int i = 0; i < data.size() - 2; i++) {
int number = Integer.parseInt(data.get(i)) + Integer.parseInt(data.get(i+1)) + Integer.parseInt(data.get(i+2));
if (number > depth) {
tot++;
}
depth = number;
}
System.out.println(tot);
}
}