Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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
```