Skip to content

Commit b801a24

Browse files
build(2020-day-12): stub out day 12
1 parent 1472997 commit b801a24

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

2020/day-12/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// eslint-disable-next-line no-unused-vars
2+
const console = require('../helpers')
3+
require('./solution')

2020/day-12/input.txt

Whitespace-only changes.

2020/day-12/solution.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const filePath = path.join(__dirname, 'input.txt')
4+
const { inputToArray } = require('../../2018/inputParser')
5+
6+
fs.readFile(filePath, { encoding: 'utf8' }, (err, initData) => {
7+
if (err) throw err
8+
9+
initData = inputToArray(initData.trim())
10+
11+
const resetInput = () => {
12+
// Deep copy to ensure we aren't mutating the original data
13+
return JSON.parse(JSON.stringify(initData))
14+
}
15+
16+
const part1 = () => {
17+
const data = resetInput()
18+
console.debug(data)
19+
return 'No answer yet'
20+
}
21+
22+
const part2 = () => {
23+
const data = resetInput()
24+
console.debug(data)
25+
return 'No answer yet'
26+
}
27+
const answers = []
28+
answers.push(part1())
29+
answers.push(part2())
30+
31+
answers.forEach((ans, idx) => {
32+
console.info(`-- Part ${idx + 1} --`)
33+
console.info(`Answer: ${ans}`)
34+
})
35+
})

0 commit comments

Comments
 (0)