Solutions to Advent of Code implemented in Rust and exposed as a Java library using JNI.
See src/lib.rs, which uses the jni-rs Rust bindings to JNI to expose the solutions implemented in the core crate. This is then used by Solver.java and loaded by JarNativeLibraryLoader.
The Maven group ID is net.fornwall
and its artifact ID is aoc
.
To add a dependency using Maven:
<dependency>
<groupId>net.fornwall</groupId>
<artifactId>aoc</artifactId>
<version>2022.0.66</version>
</dependency>
To add a dependency using Gradle:
dependencies {
implementation 'net.fornwall:aoc:2022.0.66'
}
Answers can then be computed using Solver.solve():
import net.fornwall.aoc.Solver;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) throws Exception {
var year = Integer.parseInt(args[0]);
var day = Integer.parseInt(args[1]);
var part = Integer.parseInt(args[2]);
var input = new String(System.in.readAllBytes(), StandardCharsets.UTF_8);
var answer = Solver.solve(year, day, part, input);
System.out.println(answer);
}
}