Skip to content

Commit 293806e

Browse files
committed
Stub out day 18 in Java
1 parent a222185 commit 293806e

File tree

8 files changed

+3568
-0
lines changed

8 files changed

+3568
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ My solutions to the [Advent of Code 2024](https://adventofcode.com/2024), writte
2323
- [x] [**Day 15**](day15): [C++](day15/src/day15.cpp)
2424
- [x] [**Day 16**](day16): [Kotlin](day16/src/day16.kts)
2525
- [x] [**Day 17**](day17): [C#](day17/src/day17.cs) (using Z3 to solve part 2)
26+
- [ ] [**Day 18**](day18): [Java](day18/src/Day18.java)
2627

2728
## Development
2829

day18/derivation.nix

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{ stdenv, jdk21 }:
2+
stdenv.mkDerivation {
3+
name = "advent-of-code-2024-day18";
4+
src = ./src;
5+
6+
buildInputs = [
7+
jdk21
8+
];
9+
10+
buildPhase = ''
11+
javac Day18.java
12+
'';
13+
14+
installPhase = ''
15+
mkdir -p $out/{bin,share}
16+
cp *.class $out/share
17+
18+
cat <<EOF > $out/bin/day18
19+
#!/bin/sh
20+
"${jdk21.outPath}/bin/java" -classpath "\$(dirname "\$0")/../share" Day18 "\$@"
21+
EOF
22+
23+
chmod +x $out/bin/day18
24+
'';
25+
}

day18/flake.lock

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

day18/flake.nix

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
description = "Advent of Code 2024 - Day 18 solution";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
};
7+
8+
outputs = { self, nixpkgs }:
9+
let
10+
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
11+
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
12+
in {
13+
packages = forAllSystems (system:
14+
let
15+
pkgs = import nixpkgs { inherit system; };
16+
in {
17+
default = pkgs.callPackage ./derivation.nix {};
18+
}
19+
);
20+
21+
apps = forAllSystems (system: {
22+
default = {
23+
type = "app";
24+
program = "${self.packages.${system}.default}/bin/day18";
25+
};
26+
});
27+
};
28+
}

day18/resources/demo.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
5,4
2+
4,2
3+
4,5
4+
3,0
5+
2,1
6+
6,3
7+
2,4
8+
1,5
9+
0,6
10+
3,3
11+
2,6
12+
5,1
13+
1,2
14+
5,5
15+
2,5
16+
6,5
17+
1,4
18+
0,4
19+
6,4
20+
1,1
21+
6,1
22+
1,0
23+
0,5
24+
1,6
25+
2,0

0 commit comments

Comments
 (0)