8000 Prepare for Advent of Code 2021 · l0s/advent-of-code-java@361742a · GitHub
[go: up one dir, main page]

Skip to content

Commit 361742a

Browse files
committed
Prepare for Advent of Code 2021
1 parent 58b48d4 commit 361742a

27 files changed

+39
-3043
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Advent of Code 2020 (Java)
1+
# Advent of Code 2021 (Java)
22

33
## Other Editions
44

5-
* 2020 Advent of Code ([Rust](https://github.com/l0s/advent-of-code-rust))
5+
* 2020 Advent of Code ([Java](https://github.com/l0s/advent-of-code-java/tree/2020)|[Rust](https://github.com/l0s/advent-of-code-rust))

pom.xml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,37 @@
66

77
<groupId>com.macasaet</groupId>
88
<artifactId>advent-of-code</artifactId>
9-
<version>0.2020.0-SNAPSHOT</version>
9+
<version>0.2021.0-SNAPSHOT</version>
1010

11-
<name>Advent of Code 2020</name>
11+
<name>Advent of Code 2021</name>
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<maven.compiler.source>17</maven.compiler.source>
1616
<maven.compiler.target>17</maven.compiler.target>
1717
</properties>
1818

19+
<dependencies>
20+
<dependency>
21+
<groupId>org.junit.jupiter</groupId>
22+
<artifactId>junit-jupiter</artifactId>
23+
<version>5.8.2</version>
24+
</dependency>
25+
</dependencies>
26+
27+
<build>
28+
<plugins>
29+
<plugin>
30+
<groupId>org.apache.maven.plugins</groupId>
31+
<artifactId>maven-surefire-plugin</artifactId>
32+
<version>3.0.0-M5</version>
33+
<configuration>
34+
<includes>
35+
<include>Day*.java</include>
36+
</includes>
37+
</configuration>
38+
</plugin>
39+
</plugins>
40+
</build>
41+
1942
</project>

src/test/java/com/macasaet/Day01.java

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,25 @@
11
package com.macasaet;
22

3-
import java.io.IOException;
4-
import java.util.ArrayList;
5-
import java.util.List;
6-
import java.util.Spliterator;
3+
import java.util.stream.Stream;
74
import java.util.stream.StreamSupport;
85

6+
import org.junit.jupiter.api.Test;
7+
98

109
public class Day01 {
1110

12-
public static void main(String[] args) throws IOException {
13-
try( var spliterator = new LineSpliterator(Day01.class.getResourceAsStream("/day-1-input.txt")) ) {
14-
// part1(spliterator);
15-
part2(spliterator);
16-
}
11+
protected Stream<String> getInput() {
12+
return StreamSupport.stream(new LineSpliterator(getClass().getResourceAsStream("/day-1-input.txt")),
13+
false);
1714
}
1815

19-
protected static void part1(final Spliterator<String> spliterator) {
20-
final var items = StreamSupport.stream(spliterator, false)
21-
.mapToInt(Integer::parseInt)
22-
.filter(candidate -> 6D4E candidate <= 2020) // filter out the obvious
23-
.sorted() // sort to ensure the complement is to the left
24-
.collect(ArrayList<Integer>::new, List::add, List::addAll);
25-
for( int i = items.size(); --i >= 0; ) {
26-
final int x = items.get(i);
27-
for( int j = i; --j >= 0; ) { // avoid retrying combinations
28-
final int y = items.get(j);
29-
if( x + y == 2020 ) {
30-
System.out.println( "" + ( x * y ) );
31-
return;
32-
}
33-
}
34-
}
16+
@Test
17+
public final void part1() {
18+
3519
}
3620

37-
protected static void part2(final Spliterator<String> spliterator) {
38-
final var items = StreamSupport.stream(spliterator, false)
39-
.mapToInt(Integer::parseInt)
40-
.filter(candidate -> candidate <= 2020) // filter out the obvious
41-
.sorted() // sort to ensure the complements are to the left
42-
.collect(ArrayList<Integer>::new, List::add, List::addAll);
43-
for( int i = items.size(); --i >= 0; ) {
44-
final int x = items.get(i);
45-
for( int j = i; --j >= 0; ) {
46-
final int y = items.get(j);
47-
for( int k = j; --k >= 0; ) {
48-
final int z = items.get(k);
49-
if( x + y + z == 2020 ) {
50-
System.out.println( "" + ( x * y * z ) );
51-
return;
52-
}
53-
}
54-
55-
}
56-
}
21+
@Test
22+
public final void part2() {
23+
5724
}
5825
}

src/test/java/com/macasaet/Day02.java

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/test/java/com/macasaet/Day03.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/test/java/com/macasaet/Day04.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0