setting up some java boilerplate
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
.cookie
|
||||
*/inputs
|
||||
**/resources
|
||||
|
||||
20
main.java.tmpl
Normal file
20
main.java.tmpl
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
8
run.sh
8
run.sh
@@ -1,16 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
__year=2024
|
||||
|
||||
__day="${1}"
|
||||
if [ -z "${__day}" ]; then
|
||||
__day=$(date '+%d')
|
||||
fi
|
||||
|
||||
padded=$(printf "%02g" ${__day})
|
||||
if [ -f "${padded}/index.ts" ]; then
|
||||
cd $padded
|
||||
npx tsx "index.ts" 2>/dev/null
|
||||
if [ -f "src/Day${padded}.java" ]; then
|
||||
cd src
|
||||
java "Day${padded}.java" 2>/dev/null
|
||||
cd - >/dev/null
|
||||
else
|
||||
echo "day not found"
|
||||
|
||||
21
src/Day00.java
Normal file
21
src/Day00.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
7
today.sh
7
today.sh
@@ -13,9 +13,10 @@ touch ${padded}/inputs/testinput
|
||||
if [ ! -f "${padded}/inputs/input" ]; then
|
||||
curl -s \
|
||||
-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
|
||||
if [ ! -f "${padded}/index.ts" ]; then
|
||||
cp index.ts.tmpl ${padded}/index.ts
|
||||
if [ ! -f "src/Day${padded}.java" ]; then
|
||||
cp main.java.tmpl src/Day${padded}.java
|
||||
gsed -i '' "s/00/${padded}/g" src/Day${padded}.java
|
||||
fi
|
||||
open "https://adventofcode.com/${__year}/day/${__day##0}"
|
||||
|
||||
Reference in New Issue
Block a user