Skip to content

Commit 572d6bc

Browse files
refactor(2020-day-02): initialize for 2020 day 02
1 parent 5c3f908 commit 572d6bc

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

2020/day-02/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./solution')

2020/day-02/input.txt

Whitespace-only changes.

2020/day-02/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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy