mirror of
https://github.com/cupcakearmy/advent-of-code.git
synced 2024-12-24 09:06:26 +00:00
Compare commits
No commits in common. "40e3c65a5bd2e803d9171073a232ad1f82bdbc74" and "4a876daa71368ebb20d5f3ed8f1bdaf53bf4575e" have entirely different histories.
40e3c65a5b
...
4a876daa71
57
README.md
57
README.md
@ -1,13 +1,5 @@
|
|||||||
# Advent Of Code
|
# Advent Of Code
|
||||||
|
|
||||||
Template repository for Advent of Code. It automatically downloads your puzzle inputs and bootstraps files for the following languages:
|
|
||||||
|
|
||||||
- Typescript
|
|
||||||
- Python
|
|
||||||
- Rust
|
|
||||||
|
|
||||||
Have fun! 🤗🎄
|
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
New "days" are generated with [`hygen`](https://github.com/jondot/hygen). This will bootstrap code for python and rust. See details about the specifica languages below
|
New "days" are generated with [`hygen`](https://github.com/jondot/hygen). This will bootstrap code for python and rust. See details about the specifica languages below
|
||||||
@ -16,66 +8,27 @@ New "days" are generated with [`hygen`](https://github.com/jondot/hygen). This w
|
|||||||
# First time setup
|
# First time setup
|
||||||
bun i
|
bun i
|
||||||
|
|
||||||
# Put the Advent of Code token into .env (details below)
|
# Generate
|
||||||
|
|
||||||
# Generate day
|
|
||||||
bun run gen --year 2022 --day 1
|
bun run gen --year 2022 --day 1
|
||||||
```
|
```
|
||||||
|
|
||||||
> Extracting the Advent of Code cookie
|
## Python
|
||||||
>
|
|
||||||
> 1. Navigate to https://adventofcode.com/ and login.
|
|
||||||
> 2. Open dev tools and copy the cookie named `session`.
|
|
||||||
> 3. save `TOKEN=<my-token>` to `.env`.
|
|
||||||
|
|
||||||
## Languages
|
## Rust
|
||||||
|
|
||||||
Below are instructions for the specific handling of each language included.
|
|
||||||
|
|
||||||
### Typescript
|
|
||||||
|
|
||||||
Run a single day:
|
Run a single day:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Once
|
|
||||||
bun run 2022/01/typescript/main.ts
|
|
||||||
|
|
||||||
# Rerun on change
|
|
||||||
bun run --watch 2022/01/typescript/main.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
### Python
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Get a python enabled shell, with the latest version
|
|
||||||
poetry shell
|
|
||||||
|
|
||||||
# Run once
|
|
||||||
python 2022/01/python/main.py
|
|
||||||
|
|
||||||
# Rerun on change
|
|
||||||
bunx nodemon 2022/01/python/main.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### Rust
|
|
||||||
|
|
||||||
Run a single day:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Once
|
|
||||||
cargo run --bin 2022-01
|
cargo run --bin 2022-01
|
||||||
|
|
||||||
# Rerun on change (requires: https://github.com/watchexec/cargo-watch)
|
|
||||||
cargo watch -x 'run --bin 2022-01'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Benchmark a day:
|
Bench a day:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo bench --bin 2022-01
|
cargo bench --bin 2022-01
|
||||||
```
|
```
|
||||||
|
|
||||||
Benchmark all days:
|
Bench all days:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo bench
|
cargo bench
|
||||||
|
@ -6,7 +6,9 @@ unless_exists: true
|
|||||||
|
|
||||||
from os.path import join, dirname
|
from os.path import join, dirname
|
||||||
|
|
||||||
# Setup
|
# Day <%= day %>
|
||||||
|
|
||||||
|
# Common
|
||||||
|
|
||||||
|
|
||||||
def read_input(filename):
|
def read_input(filename):
|
||||||
@ -15,25 +17,7 @@ def read_input(filename):
|
|||||||
return f.read().strip()
|
return f.read().strip()
|
||||||
|
|
||||||
|
|
||||||
TEST = read_input('test.txt')
|
test = read_input('test.txt')
|
||||||
INPUT = read_input('input.txt')
|
data = read_input('input.txt')
|
||||||
|
|
||||||
# Task
|
|
||||||
|
|
||||||
def part_a(raw: str):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def part_b(raw: str):
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Running
|
# Running
|
||||||
|
|
||||||
print('1.')
|
|
||||||
print(part_a(TEST))
|
|
||||||
print(part_a(INPUT))
|
|
||||||
|
|
||||||
print('\n2.')
|
|
||||||
print('1.')
|
|
||||||
print(part_b(TEST))
|
|
||||||
print(part_b(INPUT))
|
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
to: <%= dir %>/typescript/main.ts
|
|
||||||
unless_exists: true
|
|
||||||
---
|
|
||||||
import fs from 'node:fs'
|
|
||||||
import path from 'node:path'
|
|
||||||
|
|
||||||
// SETUP
|
|
||||||
const INPUT = fs.readFileSync(path.join(__dirname, '../input.txt'), 'utf-8').trim()
|
|
||||||
const TEST = fs.readFileSync(path.join(__dirname, '../test.txt'), 'utf-8').trim()
|
|
||||||
|
|
||||||
// TASK
|
|
||||||
|
|
||||||
function partA(input: string) {}
|
|
||||||
|
|
||||||
function partB(input: string) {}
|
|
||||||
|
|
||||||
console.log('Part A:')
|
|
||||||
partA(TEST)
|
|
||||||
partA(INPUT)
|
|
||||||
|
|
||||||
console.log('Part B:')
|
|
||||||
partA(TEST)
|
|
||||||
partB(INPUT)
|
|
@ -1,14 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "advent-of-code",
|
|
||||||
"type": "module",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"gen": "bun hygen riddle new"
|
"gen": "bun hygen riddle new"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tsconfig/strictest": "^2.0.2",
|
|
||||||
"axios": "^1.6.0",
|
"axios": "^1.6.0",
|
||||||
"bun-types": "latest",
|
"hygen": "^6.2.11"
|
||||||
"hygen": "^6.2.11",
|
|
||||||
"typescript": "^5.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["@tsconfig/strictest"],
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["ESNext"],
|
|
||||||
"module": "esnext",
|
|
||||||
"target": "esnext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"noEmit": true,
|
|
||||||
"types": ["bun-types"]
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user