diff --git a/README.md b/README.md index bf95cb0..d109947 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ -# Advent of Code Template +# Advent of Code 2020 -Advent of Code Template using Node JS for Current Year. +My solutions for Advent of Code 2020. ## Setup -If using the Advent of Code Template repo; click [**`Use this template`**](https://github.com/johnbeech/advent-of-code-nodejs-template/generate) and set a new repository name. Clone this repo, then run `npm install` to install dependencies. -If this a brand new repository, run: `node setup` to configure it for Current Year and check in the changes. ## Running diff --git a/package.json b/package.json index 7c4c2d4..019af4c 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "advent-of-code-template", - "logName": "Advent of Code Template", + "name": "advent-of-code-2020", + "logName": "Advent of Code 2020", "version": "1.0.0", - "description": "Advent of Code Template using Node JS for Current Year.", + "description": "Advent of Code 2020 using Node JS for Current Year.", "main": "run.js", "scripts": { "start": "npm run test && node run.js", diff --git a/setup.js b/setup.js deleted file mode 100644 index 26027f7..0000000 --- a/setup.js +++ /dev/null @@ -1,51 +0,0 @@ -const path = require('path') -const { read, write, position, run } = require('promise-path') - -const fromHere = position(__dirname) -const report = (...messages) => console.log(`[${require(fromHere('./package.json')).logName} / ${__filename.split(path.sep).pop().split('.js').shift()}]`, ...messages) - -async function replaceInFile (filename, search, replace) { - const haystack = await read(filename, 'utf8') - const ashes = haystack.replace(search, replace) - return write(filename, ashes, 'utf8') -} - -async function setup () { - const currentPath = fromHere('/') - const currentFolder = currentPath.split('/').reverse()[1] - - report('Setting up template from:', currentFolder) - - const currentYear = currentFolder.split('-').pop() - - if (currentYear === 'template') { - console.error(' No current year provided.') - console.error(' Please re-run setup after renaming the repo, e.g.: advent-of-code-2020, advent-of-code-2021, advent-of-code-2022, etc.') - console.error('') - process.exit(0) - } - - report('Replacing strings in templates') - await replaceInFile('README.md', 'If using the Advent of Code Template repo; click [**`Use this template`**](https://github.com/johnbeech/advent-of-code-nodejs-template/generate) and set a new repository name.\n', '') - await replaceInFile('README.md', 'If this a brand new repository, run: `node setup` to configure it for Current Year and check in the changes.\n', '') - - await replaceInFile('package.json', /Advent of Code Template/g, `Advent of Code ${currentYear}`) - await replaceInFile('README.md', '# Advent of Code Template', `# Advent of Code ${currentYear}`) - - await replaceInFile('package.json', 'Advent of Code Template using Node JS for Current Year.', `My solutions for Advent of Code ${currentYear}.`) - await replaceInFile('README.md', 'Advent of Code Template using Node JS for Current Year.', `My solutions for Advent of Code ${currentYear}.`) - - await replaceInFile('package.json', 'advent-of-code-template', currentFolder) - - report('Removing setup script') - await run(`rm ${fromHere('setup.js')}`) - - report('Committing changes and pushing to remote') - await run('git add .') - await run(`git commit -m "Setup template for Current Year (${currentYear})"`) - await run('git push') - - report(`All done! ${currentYear} setup and ready to go~`) -} - -setup() diff --git a/solutions/day3/input.txt b/solutions/day3/input.txt new file mode 100644 index 0000000..e69de29 diff --git a/solutions/day3/solution.js b/solutions/day3/solution.js new file mode 100644 index 0000000..bcee989 --- /dev/null +++ b/solutions/day3/solution.js @@ -0,0 +1,24 @@ +const path = require('path') +const { read, position } = require('promise-path') +const fromHere = position(__dirname) +const report = (...messages) => console.log(`[${require(fromHere('../../package.json')).logName} / ${__dirname.split(path.sep).pop()}]`, ...messages) + +async function run () { + const input = (await read(fromHere('input.txt'), 'utf8')).trim() + + await solveForFirstStar(input) + await solveForSecondStar(input) +} + +async function solveForFirstStar (input) { + const solution = 'UNSOLVED' + // report('Input:', input); + report('Solution 1:', solution) +} + +async function solveForSecondStar (input) { + const solution = 'UNSOLVED' + report('Solution 2:', solution) +} + +run() diff --git a/solutions/day3/viewer.html b/solutions/day3/viewer.html new file mode 100644 index 0000000..d583fae --- /dev/null +++ b/solutions/day3/viewer.html @@ -0,0 +1,43 @@ + + + + Solution Viewer + + + + + +
+

Solution Viewer ({{ solutionTitle }})

+

For interesting problems; this page can be used as a dynamic viewer.

+

input.txt

+
{{ inputText }}
+

solution.js

+
{{ solutionText }}
+
+ + + \ No newline at end of file