Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiritaniayaka/aoc-toolkit
A toolkit for Advent of Code.
https://github.com/kiritaniayaka/aoc-toolkit
advent-of-code deno
Last synced: 27 days ago
JSON representation
A toolkit for Advent of Code.
- Host: GitHub
- URL: https://github.com/kiritaniayaka/aoc-toolkit
- Owner: KiritaniAyaka
- Created: 2024-12-01T05:23:30.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-12-09T06:30:09.000Z (about 1 month ago)
- Last Synced: 2024-12-09T07:27:30.461Z (about 1 month ago)
- Topics: advent-of-code, deno
- Language: TypeScript
- Homepage: https://jsr.io/@kiritaniayaka/aoc-toolkit
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aoc-toolkit
A toolkit for Advent of Code.
## Usage
Import this:
```ts
import { solve } from "@kiritaniayaka/aoc-toolkit";solve((input) => { // input is a string
// your code here
});
```For example, your script is `part1.ts`. This function `solve` will automatically
read from `part1.in`, convert the return value to string and write it into
`part1.out`.## CLI
This package also provides a CLI usage. The running command is a little verbose,
it's recommend to setup a alias: (Following examples are generated by AI)Bash (`.bashrc`):
```bash
aoc() {
if [ -z "$1" ]; then
echo "Usage: aoc [arguments]"
return 1
fi
local subcommand="$1"
shift
local args=("$@")
deno run -A "jsr:@kiritaniayaka/aoc-toolkit/$subcommand" "${args[@]}"
}
```PowerShell (`Microsoft.PowerShell_profile.ps1`):
```pwsh
function aoc {
param (
[string]$Subcommand,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Args
)
if (-not $Subcommand) {
Write-Host "Usage: aoc [arguments]"
return
}
$denoCommand = "deno"
$denoArgs = @("run", "-A", "jsr:@kiritaniayaka/aoc-toolkit/$subcommand") + $args
& $denoCommand $denoArgs
}
```### Create
```sh
deno run -A jsr:@kiritaniayaka/aoc-toolkit/new
```It automatically predicts what day you are going.
Or specify days with:
```sh
deno run -A jsr:@kiritaniayaka/aoc-toolkit/new day1
```### Run
Running all script in directory `day1` with every input files `*.in`, and output
to `*.out`.```sh
deno run -A jsr:@kiritaniayaka/aoc-toolkit/run day1
```### Clean
Removing all `*.out` files in direcotry. Current working directory is applied if
directory not specified.```sh
deno run -A jsr:@kiritaniayaka/aoc-toolkit/clean day1
```