Skip to content

Commit 40a76d9

Browse files
feat(2019-day-02): calculate answer for part 1
1 parent d4d744e commit 40a76d9

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

2019/day-02/input.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,10,19,2,6,19,23,1,23,5,27,1,27,13,31,2,6,31,35,1,5,35,39,1,39,10,43,2,6,43,47,1,47,5,51,1,51,9,55,2,55,6,59,1,59,10,63,2,63,9,67,1,67,5,71,1,71,5,75,2,75,6,79,1,5,79,83,1,10,83,87,2,13,87,91,1,10,91,95,2,13,95,99,1,99,9,103,1,5,103,107,1,107,10,111,1,111,5,115,1,115,6,119,1,119,10,123,1,123,10,127,2,127,13,131,1,13,131,135,1,135,10,139,2,139,6,143,1,143,9,147,2,147,6,151,1,5,151,155,1,9,155,159,2,159,6,163,1,163,2,167,1,10,167,0,99,2,14,0,0

2019/day-02/solution.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const filePath = path.join(__dirname, 'input.txt')
4+
const { runProgram } = require('./intcodeParser')
5+
const { inputToArray } = require('../../2018/inputParser')
6+
7+
fs.readFile(filePath, { encoding: 'utf8' }, (err, data) => {
8+
if (err) throw err
9+
10+
data = inputToArray(data.trim())
11+
// Manipulate input per puzzle instructions for Part 1
12+
data[1] = 12
13+
data[2] = 2
14+
15+
runProgram({ data })
16+
const answer = data[0]
17+
18+
console.log('-- Part 1 --')
19+
console.log(`Answer: ${answer}`)
20+
})

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
require('./2019/day-01/part-1/solution')
1+
require('./2019/day-02/solution')

0 commit comments

Comments
 (0)