setting up some java boilerplate

This commit is contained in:
2025-11-30 15:26:36 -05:00
parent 3d449572c0
commit 3eb6aa5002
6 changed files with 51 additions and 9 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
.cookie .cookie
*/inputs **/resources

20
main.java.tmpl Normal file
View File

@@ -0,0 +1,20 @@
package src;
import java.io.FileReader;
import java.util.Scanner;
public class Day00 {
public static void main(String[] args) {
try (Scanner scanner = new Scanner(new FileReader("resources/00/input")).useDelimiter("\\R")) {
StringBuilder sb = new StringBuilder();
while (scanner.hasNext()) {
sb.append(scanner.next());
sb.append("\n");
}
String input = sb.toString();
System.out.println(input);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}

View File

@@ -1,3 +1,5 @@
# AOC 2025 # AOC 2025
Java this year!
<https://adventofcode.com/2025/> <https://adventofcode.com/2025/>

8
run.sh
View File

@@ -1,16 +1,14 @@
#!/bin/bash #!/bin/bash
__year=2024
__day="${1}" __day="${1}"
if [ -z "${__day}" ]; then if [ -z "${__day}" ]; then
__day=$(date '+%d') __day=$(date '+%d')
fi fi
padded=$(printf "%02g" ${__day}) padded=$(printf "%02g" ${__day})
if [ -f "${padded}/index.ts" ]; then if [ -f "src/Day${padded}.java" ]; then
cd $padded cd src
npx tsx "index.ts" 2>/dev/null java "Day${padded}.java" 2>/dev/null
cd - >/dev/null cd - >/dev/null
else else
echo "day not found" echo "day not found"

21
src/Day00.java Normal file
View File

@@ -0,0 +1,21 @@
package src;
import java.io.FileReader;
import java.util.Scanner;
public class Day00 {
public static void main(String[] args) {
try (Scanner scanner = new Scanner(new FileReader("resources/00/input")).useDelimiter("\\R")) {
StringBuilder sb = new StringBuilder();
while (scanner.hasNext()) {
sb.append(scanner.next());
sb.append("\n");
}
String input = sb.toString();
System.out.println(input);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}

View File

@@ -13,9 +13,10 @@ touch ${padded}/inputs/testinput
if [ ! -f "${padded}/inputs/input" ]; then if [ ! -f "${padded}/inputs/input" ]; then
curl -s \ curl -s \
-A "https://git.yetaga.in/alazyreader/AdventOfCode${__year}/" \ -A "https://git.yetaga.in/alazyreader/AdventOfCode${__year}/" \
-H "Cookie: session=`cat .cookie`" https://adventofcode.com/${__year}/day/${__day##0}/input > "${padded}/inputs/input" -H "Cookie: session=`cat .cookie`" https://adventofcode.com/${__year}/day/${__day##0}/input > "src/resources/inputs/${padded}/input"
fi fi
if [ ! -f "${padded}/index.ts" ]; then if [ ! -f "src/Day${padded}.java" ]; then
cp index.ts.tmpl ${padded}/index.ts cp main.java.tmpl src/Day${padded}.java
gsed -i '' "s/00/${padded}/g" src/Day${padded}.java
fi fi
open "https://adventofcode.com/${__year}/day/${__day##0}" open "https://adventofcode.com/${__year}/day/${__day##0}"