Skip to content

Commit 5c0cc97

Browse files
committed
feat: init
0 parents  commit 5c0cc97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+10345
-0
lines changed

.eslintrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": ["next/core-web-vitals", "prettier"],
3+
"settings": {
4+
"import/resolver": {
5+
"typescript": {}
6+
}
7+
}
8+
}

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
/dist
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
.pnpm-debug.log*
28+
29+
# local env files
30+
.env
31+
.env*.local
32+
33+
# vercel
34+
.vercel
35+
36+
# typescript
37+
*.tsbuildinfo
38+
next-env.d.ts
39+
40+
.vscode
41+
/data/*-input.txt
42+
.idea

.swcrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"sourceMaps": true,
3+
"jsc": {
4+
"parser": {
5+
"syntax": "typescript"
6+
},
7+
"baseUrl": "./",
8+
"paths": {
9+
"~/*": ["src/*"]
10+
}
11+
},
12+
"module": {
13+
"type": "commonjs"
14+
}
15+
}

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# AoC 2017
2+
3+
## Initial Setup
4+
5+
Just cloned the repo? Follow these instructions to get set up.
6+
7+
### Step 1 - Install dependencies.
8+
9+
```shell
10+
npm install
11+
```
12+
13+
### Step 2 - Add puzzle inputs.
14+
15+
Notice the new `data` directory, created by the `postinstall` (AKA `setup`) script.
16+
It should have prepopulated the folder with two blank files for each puzzle X:
17+
18+
- `puzzleX-example.txt`
19+
- `puzzleX-input.txt`
20+
21+
This is where you'll add your puzzle inputs; just paste the respective contents into each file.
22+
23+
> [!TIP]
24+
>
25+
> You can automate the data entry process by adding your session token to the `.env` file.
26+
> You can find your session key in the 'session' cookie at: https://adventofcode.com.
27+
> Then run the `npm run setup` command to fetch the inputs for all puzzles.
28+
29+
### Step 3 - Run puzzle solution(s).
30+
31+
The `src/index.ts` file contains a runner that will run the puzzle solutions.
32+
33+
You can choose to run any subset of the existing puzzle solutions.
34+
You can also choose to run either the example or main data set, or both, for any puzzle.
35+
36+
```typescript
37+
// await puzzle1.run();
38+
// await puzzle2.run();
39+
// await puzzle3.run();
40+
// await puzzle4.run();
41+
await puzzle5.run({
42+
example: true,
43+
mainProblem: false,
44+
});
45+
```
46+
The above example will just run the example data set for puzzle 5.
47+
48+
## New Puzzle Setup
49+
50+
Ready to start a new puzzle? Follow these instructions to generate the necessary files.
51+
52+
### Step 1 - Generate new puzzle files.
53+
54+
The script will automatically detect which puzzle you're on (based on existence of files in `puzzles` folder), and generate the necessary files.
55+
56+
```shell
57+
npm run generate
58+
```
59+
60+
### Step 2 - Add puzzle data.
61+
62+
Two new (blank) puzzle data files should now exist in the `data` folder:
63+
```
64+
data/puzzleX-example.ts
65+
data/puzzleX-input.ts
66+
```
67+
68+
### Step 3 - Get cracking!
69+
70+
Write puzzle code in new puzzle file:
71+
```
72+
src/puzzles/puzzleX.ts
73+
```
74+
75+
Run puzzle code as needed while solving.
76+
77+
For a single run:
78+
```shell
79+
npm start
80+
```
81+
82+
For a `nodemon` file-watched run:
83+
```shell
84+
npm run dev
85+
```
86+
87+
88+
Modify runner in `src/index.ts` to switch between example & main data sets for any puzzle.

data/puzzle1-example.txt

Whitespace-only changes.

nodemon.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"watch": ["src/", "data/"],
3+
"ext": "js,ts",
4+
"execMap": {
5+
"js": "node --inspect -r @swc-node/register",
6+
"ts": "node --inspect -r @swc-node/register"
7+
}
8+
}

0 commit comments

Comments
 (0)