diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..983f115 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,13 @@ +module.exports = { + root: true, + env: { + node: true, + }, + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], + rules: { + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + }, + ignorePatterns: ['node_modules/', 'dist/'], +} diff --git a/.gitignore b/.gitignore index 76add87..3a8ec2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -dist \ No newline at end of file +dist +package-lock.json \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..5ab48f6 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,18 @@ +{ + "trailingComma": "es5", + "tabWidth": 4, + "printWidth": 100, + "semi": false, + "singleQuote": true, + "overrides": [ + { + "files": [ + "*.yaml", + "*.yml" + ], + "options": { + "tabWidth": 2 + } + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3734ef6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8b9c838 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# Advent of Code 2021 + +## Getting started: + +``` +npm install +``` + +## Running solutions: + +``` +npm start -w day- +``` + +``` +npm start -w day-1 +``` diff --git a/__template__/index.ts b/__template__/index.ts new file mode 100644 index 0000000..12d36a8 --- /dev/null +++ b/__template__/index.ts @@ -0,0 +1,7 @@ +import { getInputAsLines, getTestInputAsLines } from '../shared/input' + +const partOne = undefined +const partTwo = undefined + +console.log('Part one:', partOne) +console.log('Part two:', partTwo) diff --git a/__template__/input.txt b/__template__/input.txt new file mode 100644 index 0000000..e69de29 diff --git a/__template__/package.json b/__template__/package.json new file mode 100644 index 0000000..313da42 --- /dev/null +++ b/__template__/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "start": "ts-node index.ts" + } +} \ No newline at end of file diff --git a/__template__/test_input.txt b/__template__/test_input.txt new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json new file mode 100644 index 0000000..cb9fedc --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "aoc2021", + "version": "1.0.0", + "description": "Advent of Code 2021", + "scripts": { + "start": "echo \"Specify a workspace, e.g: npm start -w day-1\" && exit 1", + "format": "prettier -w '**/*.ts'" + }, + "workspaces": [ + "./day-*" + ], + "author": "Bas Verhoeven", + "license": "ISC", + "devDependencies": { + "@types/node": "^16.11.11", + "@typescript-eslint/eslint-plugin": "^5.5.0", + "@typescript-eslint/parser": "^5.5.0", + "eslint": "^8.3.0", + "eslint-config-prettier": "^8.3.0", + "prettier": "^2.5.0", + "ts-node": "^10.4.0", + "typescript": "^4.5.2" + } +} \ No newline at end of file diff --git a/shared/input.ts b/shared/input.ts new file mode 100644 index 0000000..305f87d --- /dev/null +++ b/shared/input.ts @@ -0,0 +1,13 @@ +import { readFileSync } from 'node:fs' + +export function getInput(filename = 'input.txt'): string { + return readFileSync(filename, 'utf8').trim() +} + +export function getInputAsLines(filename = 'input.txt'): string[] { + return getInput(filename).split('\n') +} + +export function getTestInputAsLines(filename = 'test_input.txt'): string[] { + return getInputAsLines(filename) +}