, AutoCloseable {
+ private static final String prefix;
private final BufferedReader reader;
+ static {
+ final var properties = new Properties();
+ try {
+ final var config = LineSpliterator.class.getResourceAsStream("/config.properties");
+ if (config != null) properties.load(config);
+ } catch (final IOException ignored) {
+ }
+ prefix = properties.getProperty("prefix", "/sample");
+ }
+
public LineSpliterator(final BufferedReader reader) {
Objects.requireNonNull(reader);
this.reader = reader;
@@ -26,6 +34,10 @@ public LineSpliterator(final InputStream stream) {
this(new InputStreamReader(stream));
}
+ public LineSpliterator(final String fileName) {
+ this(LineSpliterator.class.getResourceAsStream(prefix + "/" + fileName));
+ }
+
public boolean tryAdvance(final Consumer super String> action) {
try {
final var line = reader.readLine();
@@ -35,7 +47,6 @@ public boolean tryAdvance(final Consumer super String> action) {
}
reader.close();
} catch (final IOException ioe) {
- ioe.printStackTrace();
}
return false;
}
diff --git a/src/test/resources/sample/day-01.txt b/src/test/resources/sample/day-01.txt
new file mode 100644
index 0000000..444e241
--- /dev/null
+++ b/src/test/resources/sample/day-01.txt
@@ -0,0 +1,14 @@
+1000
+2000
+3000
+
+4000
+
+5000
+6000
+
+7000
+8000
+9000
+
+10000
\ No newline at end of file
diff --git a/src/test/resources/sample/day-02.txt b/src/test/resources/sample/day-02.txt
new file mode 100644
index 0000000..25097e8
--- /dev/null
+++ b/src/test/resources/sample/day-02.txt
@@ -0,0 +1,3 @@
+A Y
+B X
+C Z
\ No newline at end of file
diff --git a/src/test/resources/sample/day-03.txt b/src/test/resources/sample/day-03.txt
new file mode 100644
index 0000000..9919ffa
--- /dev/null
+++ b/src/test/resources/sample/day-03.txt
@@ -0,0 +1,6 @@
+vJrwpWtwJgWrhcsFMMfFFhFp
+jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
+PmmdzqPrVvPwwTWBwg
+wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
+ttgJtRGJQctTZtZT
+CrZsJsPPZsGzwwsLwLmpwMDw
\ No newline at end of file
diff --git a/src/test/resources/sample/day-04.txt b/src/test/resources/sample/day-04.txt
new file mode 100644
index 0000000..99a66c5
--- /dev/null
+++ b/src/test/resources/sample/day-04.txt
@@ -0,0 +1,6 @@
+2-4,6-8
+2-3,4-5
+5-7,7-9
+2-8,3-7
+6-6,4-6
+2-6,4-8
\ No newline at end of file
diff --git a/src/test/resources/sample/day-05.txt b/src/test/resources/sample/day-05.txt
new file mode 100644
index 0000000..e98aba4
--- /dev/null
+++ b/src/test/resources/sample/day-05.txt
@@ -0,0 +1,9 @@
+ [D]
+[N] [C]
+[Z] [M] [P]
+ 1 2 3
+
+move 1 from 2 to 1
+move 3 from 1 to 3
+move 2 from 2 to 1
+move 1 from 1 to 2
\ No newline at end of file
diff --git a/src/test/resources/sample/day-06.txt b/src/test/resources/sample/day-06.txt
new file mode 100644
index 0000000..5a2b0a7
--- /dev/null
+++ b/src/test/resources/sample/day-06.txt
@@ -0,0 +1 @@
+mjqjpqmgbljsphdztnvjfqwrcgsmlb
\ No newline at end of file
diff --git a/src/test/resources/sample/day-07.txt b/src/test/resources/sample/day-07.txt
new file mode 100644
index 0000000..bcbb513
--- /dev/null
+++ b/src/test/resources/sample/day-07.txt
@@ -0,0 +1,23 @@
+$ cd /
+$ ls
+dir a
+14848514 b.txt
+8504156 c.dat
+dir d
+$ cd a
+$ ls
+dir e
+29116 f
+2557 g
+62596 h.lst
+$ cd e
+$ ls
+584 i
+$ cd ..
+$ cd ..
+$ cd d
+$ ls
+4060174 j
+8033020 d.log
+5626152 d.ext
+7214296 k
\ No newline at end of file
diff --git a/src/test/resources/sample/day-08.txt b/src/test/resources/sample/day-08.txt
new file mode 100644
index 0000000..6557024
--- /dev/null
+++ b/src/test/resources/sample/day-08.txt
@@ -0,0 +1,5 @@
+30373
+25512
+65332
+33549
+35390
\ No newline at end of file
diff --git a/src/test/resources/sample/day-09.txt b/src/test/resources/sample/day-09.txt
new file mode 100644
index 0000000..cbea2b3
--- /dev/null
+++ b/src/test/resources/sample/day-09.txt
@@ -0,0 +1,8 @@
+R 4
+U 4
+L 3
+D 1
+R 4
+D 1
+L 5
+R 2
\ No newline at end of file
diff --git a/src/test/resources/sample/day-10.txt b/src/test/resources/sample/day-10.txt
new file mode 100644
index 0000000..94cd0a8
--- /dev/null
+++ b/src/test/resources/sample/day-10.txt
@@ -0,0 +1,146 @@
+addx 15
+addx -11
+addx 6
+addx -3
+addx 5
+addx -1
+addx -8
+addx 13
+addx 4
+noop
+addx -1
+addx 5
+addx -1
+addx 5
+addx -1
+addx 5
+addx -1
+addx 5
+addx -1
+addx -35
+addx 1
+addx 24
+addx -19
+addx 1
+addx 16
+addx -11
+noop
+noop
+addx 21
+addx -15
+noop
+noop
+addx -3
+addx 9
+addx 1
+addx -3
+addx 8
+addx 1
+addx 5
+noop
+noop
+noop
+noop
+noop
+addx -36
+noop
+addx 1
+addx 7
+noop
+noop
+noop
+addx 2
+addx 6
+noop
+noop
+noop
+noop
+noop
+addx 1
+noop
+noop
+addx 7
+addx 1
+noop
+addx -13
+addx 13
+addx 7
+noop
+addx 1
+addx -33
+noop
+noop
+noop
+addx 2
+noop
+noop
+noop
+addx 8
+noop
+addx -1
+addx 2
+addx 1
+noop
+addx 17
+addx -9
+addx 1
+addx 1
+addx -3
+addx 11
+noop
+noop
+addx 1
+noop
+addx 1
+noop
+noop
+addx -13
+addx -19
+addx 1
+addx 3
+addx 26
+addx -30
+addx 12
+addx -1
+addx 3
+addx 1
+noop
+noop
+noop
+addx -9
+addx 18
+addx 1
+addx 2
+noop
+noop
+addx 9
+noop
+noop
+noop
+addx -1
+addx 2
+addx -37
+addx 1
+addx 3
+noop
+addx 15
+addx -21
+addx 22
+addx -6
+addx 1
+noop
+addx 2
+addx 1
+noop
+addx -10
+noop
+noop
+addx 20
+addx 1
+addx 2
+addx 2
+addx -6
+addx -11
+noop
+noop
+noop
\ No newline at end of file
diff --git a/src/test/resources/sample/day-11.txt b/src/test/resources/sample/day-11.txt
new file mode 100644
index 0000000..c04eddb
--- /dev/null
+++ b/src/test/resources/sample/day-11.txt
@@ -0,0 +1,27 @@
+Monkey 0:
+ Starting items: 79, 98
+ Operation: new = old * 19
+ Test: divisible by 23
+ If true: throw to monkey 2
+ If false: throw to monkey 3
+
+Monkey 1:
+ Starting items: 54, 65, 75, 74
+ Operation: new = old + 6
+ Test: divisible by 19
+ If true: throw to monkey 2
+ If false: throw to monkey 0
+
+Monkey 2:
+ Starting items: 79, 60, 97
+ Operation: new = old * old
+ Test: divisible by 13
+ If true: throw to monkey 1
+ If false: throw to monkey 3
+
+Monkey 3:
+ Starting items: 74
+ Operation: new = old + 3
+ Test: divisible by 17
+ If true: throw to monkey 0
+ If false: throw to monkey 1
\ No newline at end of file
diff --git a/src/test/resources/sample/day-12.txt b/src/test/resources/sample/day-12.txt
new file mode 100644
index 0000000..86e9cac
--- /dev/null
+++ b/src/test/resources/sample/day-12.txt
@@ -0,0 +1,5 @@
+Sabqponm
+abcryxxl
+accszExk
+acctuvwj
+abdefghi
diff --git a/src/test/resources/sample/day-13.txt b/src/test/resources/sample/day-13.txt
new file mode 100644
index 0000000..27c8912
--- /dev/null
+++ b/src/test/resources/sample/day-13.txt
@@ -0,0 +1,23 @@
+[1,1,3,1,1]
+[1,1,5,1,1]
+
+[[1],[2,3,4]]
+[[1],4]
+
+[9]
+[[8,7,6]]
+
+[[4,4],4,4]
+[[4,4],4,4,4]
+
+[7,7,7,7]
+[7,7,7]
+
+[]
+[3]
+
+[[[]]]
+[[]]
+
+[1,[2,[3,[4,[5,6,7]]]],8,9]
+[1,[2,[3,[4,[5,6,0]]]],8,9]
\ No newline at end of file
diff --git a/src/test/resources/sample/day-14.txt b/src/test/resources/sample/day-14.txt
new file mode 100644
index 0000000..1926028
--- /dev/null
+++ b/src/test/resources/sample/day-14.txt
@@ -0,0 +1,2 @@
+498,4 -> 498,6 -> 496,6
+503,4 -> 502,4 -> 502,9 -> 494,9
\ No newline at end of file
diff --git a/src/test/resources/sample/day-15.txt b/src/test/resources/sample/day-15.txt
new file mode 100644
index 0000000..652e631
--- /dev/null
+++ b/src/test/resources/sample/day-15.txt
@@ -0,0 +1,14 @@
+Sensor at x=2, y=18: closest beacon is at x=-2, y=15
+Sensor at x=9, y=16: closest beacon is at x=10, y=16
+Sensor at x=13, y=2: closest beacon is at x=15, y=3
+Sensor at x=12, y=14: closest beacon is at x=10, y=16
+Sensor at x=10, y=20: closest beacon is at x=10, y=16
+Sensor at x=14, y=17: closest beacon is at x=10, y=16
+Sensor at x=8, y=7: closest beacon is at x=2, y=10
+Sensor at x=2, y=0: closest beacon is at x=2, y=10
+Sensor at x=0, y=11: closest beacon is at x=2, y=10
+Sensor at x=20, y=14: closest beacon is at x=25, y=17
+Sensor at x=17, y=20: closest beacon is at x=21, y=22
+Sensor at x=16, y=7: closest beacon is at x=15, y=3
+Sensor at x=14, y=3: closest beacon is at x=15, y=3
+Sensor at x=20, y=1: closest beacon is at x=15, y=3
\ No newline at end of file
diff --git a/src/test/resources/sample/day-18.txt b/src/test/resources/sample/day-18.txt
new file mode 100644
index 0000000..d18bf98
--- /dev/null
+++ b/src/test/resources/sample/day-18.txt
@@ -0,0 +1,13 @@
+2,2,2
+1,2,2
+3,2,2
+2,1,2
+2,3,2
+2,2,1
+2,2,3
+2,2,4
+2,2,6
+1,2,5
+3,2,5
+2,1,5
+2,3,5
\ No newline at end of file
diff --git a/src/test/resources/sample/day-20.txt b/src/test/resources/sample/day-20.txt
new file mode 100644
index 0000000..5cbf3d9
--- /dev/null
+++ b/src/test/resources/sample/day-20.txt
@@ -0,0 +1,7 @@
+1
+2
+-3
+3
+-2
+0
+4
\ No newline at end of file
diff --git a/src/test/resources/sample/day-21.txt b/src/test/resources/sample/day-21.txt
new file mode 100644
index 0000000..7993b87
--- /dev/null
+++ b/src/test/resources/sample/day-21.txt
@@ -0,0 +1,15 @@
+root: pppw + sjmn
+dbpl: 5
+cczh: sllz + lgvd
+zczc: 2
+ptdq: humn - dvpt
+dvpt: 3
+lfqf: 4
+humn: 5
+ljgn: 2
+sjmn: drzm * dbpl
+sllz: 4
+pppw: cczh / lfqf
+lgvd: ljgn * ptdq
+drzm: hmdt - zczc
+hmdt: 32
\ No newline at end of file
diff --git a/src/test/resources/sample/day-23.txt b/src/test/resources/sample/day-23.txt
new file mode 100644
index 0000000..7ac3ba9
--- /dev/null
+++ b/src/test/resources/sample/day-23.txt
@@ -0,0 +1,7 @@
+....#..
+..###.#
+#...#.#
+.#...##
+#.###..
+##.#.##
+.#..#..
\ No newline at end of file
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy