Solutions to various programming koans bundled with a mini-framework capable of executing them against input of user's choice - whether from a command line, a file, or a URL.
Totally not named after Nakahara Misaki
from Welcome to the N.H.K.
Assumes git
and JDK >= 8 (possibly from here):
git clone https://gitgud.io/mataha/misaki # or wherever it's hosted right now
cd misaki
./gradlew build
Command-line help page is available under ./run --help
.
By default, misaki
reads data from standard input:
$ ./run "Advent of Code" "Not Quite Lisp"
Enter your puzzle input:
()()))())(()))()()(())(())()()(
^D
[-3, 5]
where ^D
is EOF
(^Z
on Windows)
$ ./run "Advent of Code" "Some Assembly Required" \
> -i "samples/adventofcode/2015/07/input.txt"
[3176, 14710]
$ ./run "Advent of Code" "All in a Single Night" \
> -i "samples/adventofcode/2015/09/input.txt" --measure
[141, 736]
That took: 127ms
Input can also be fetched from a URL:
$ ./run "Advent of Code" "Aunt Sue" \
> --url "https://adventofcode.com/2015/day/16/input"
However, this won't work when obtaining input directly from Advent of Code:
Error: ClientRequestException: Client request(https://adventofcode.com/2015/day/16/input) invalid: 400 Bad Request
Aborted!
In that case, a session token is required. misaki
allows multiple ways
of setting it:
-
As a command-line option:
$ ./run "Advent of Code" "Aunt Sue" \ > --url "https://adventofcode.com/2015/day/16/input" \ > --token 57e8444ca2478daf7c97a1ffaba582ab224...
-
As an environment variable:
$ export MISAKI_APP_TOKEN=57e8444ca2478daf7c97a1ffaba582ab224... $ ./run "Advent of Code" "Aunt Sue" \ > --url "https://adventofcode.com/2015/day/16/input"
-
From an environment variable file:
$ echo MISAKI_APP_TOKEN=57e8444ca2478daf7c97a1ffaba582ab224... > .env $ ./run "Advent of Code" "Aunt Sue" \ > --url "https://adventofcode.com/2015/day/16/input"
Sample output:
[373, 260]
misaki
, much like javac
, supports argument files:
$ ./run @"samples/adventofcode/2015/05/argfile"
[258, 53]
Where argfile
contains:
"Advent of Code" "Doesn't He Have Intern-Elves For This?"
-i "samples/adventofcode/2015/05/input.txt"
MIT. See LICENSE.