Skip to content

Commit a178f3a

Browse files
committed
2023-q16 abandonment
1 parent 5235768 commit a178f3a

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.icecreamhead.adventofcode.q16;
2+
3+
import java.util.HashSet;
4+
import java.util.List;
5+
import java.util.Set;
6+
7+
public class TheFloorWillBeLava {
8+
9+
long part1(char[][] input) throws InterruptedException {
10+
HashSet<Beam> beams = new HashSet<Beam>();
11+
beams.add(Beam.START);
12+
HashSet<Pos> visited = new HashSet<Pos>();
13+
14+
// print(input, beams);
15+
while (!beams.isEmpty()) {
16+
17+
for (Beam beam : beams) {
18+
19+
20+
21+
22+
}
23+
24+
break;
25+
26+
// print(input, beams);
27+
// Thread.sleep(1000);
28+
}
29+
30+
return visited.size();
31+
}
32+
33+
private void print(char[][] input, Set<Beam> beams) {
34+
for (int y = 0; y < input.length; y++) {
35+
for (int x = 0; x < input[y].length; x++) {
36+
if (has(beams, x, y))
37+
System.out.print("#");
38+
else
39+
System.out.print(input[y][x]);
40+
}
41+
System.out.println();
42+
}
43+
System.out.println();
44+
}
45+
46+
private static boolean has(Set<Beam> beams, int x, int y) {
47+
return beams.stream().anyMatch(b -> b.x() == x && b.y() == y);
48+
}
49+
50+
enum Direction {
51+
UP, DOWN, LEFT, RIGHT
52+
}
53+
54+
55+
private record Pos(int x, int y) {}
56+
private record Beam(Pos pos, Direction direction) {
57+
private static final Beam START = new Beam(new Pos(0,0), Direction.RIGHT);
58+
private int x() {
59+
return pos.x;
60+
}
61+
private int y() {
62+
return pos.y;
63+
}
64+
}
65+
}

twentytwentythree/src/main/resources/q16/puzzle.txt

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.|...\....
2+
|.-.\.....
3+
.....|-...
4+
........|.
5+
..........
6+
.........\
7+
..../.\\..
8+
.-.-/..|..
9+
.|....-|.\
10+
..//.|....
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.icecreamhead.adventofcode.q16;
2+
3+
import com.icecreamhead.adventofcode.util.InputLoader;
4+
import org.assertj.core.api.Assertions;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
import static org.junit.jupiter.api.Assertions.*;
9+
10+
class TheFloorWillBeLavaTest {
11+
12+
private final TheFloorWillBeLava underTest = new TheFloorWillBeLava();
13+
14+
private static final char[][] SAMPLE = InputLoader.loadGrid("q16/sample.txt");
15+
@Test
16+
void part1_sample() throws InterruptedException {
17+
assertThat(underTest.part1(SAMPLE)).isEqualTo(46);
18+
}
19+
}

0 commit comments

Comments
 (0)