2019 day 2 + some other stuff
This commit is contained in:
parent
6facbd56de
commit
12d0551bb4
|
@ -1,17 +1,17 @@
|
||||||
# [2018](https://adventofcode.com/2018 "2018 puzzle calendar")
|
# [2018](https://adventofcode.com/2018 "2018 puzzle calendar")
|
||||||
1 | [:star: :star:](https://adventofcode.com/2015/day/1 "see puzzle")
|
1 | [:star: :star:](https://adventofcode.com/2018/day/1 "see puzzle")
|
||||||
--: | :--
|
--: | :--
|
||||||
2 | [:star: :star:](https://adventofcode.com/2015/day/2 "see puzzle")
|
2 | [:star: :star:](https://adventofcode.com/2018/day/2 "see puzzle")
|
||||||
3 | [:star: :star:](https://adventofcode.com/2015/day/3 "see puzzle")
|
3 | [:star: :star:](https://adventofcode.com/2018/day/3 "see puzzle")
|
||||||
4 | [:star: :star:](https://adventofcode.com/2015/day/4 "see puzzle")
|
4 | [:star: :star:](https://adventofcode.com/2018/day/4 "see puzzle")
|
||||||
5 | [:star: :star:](https://adventofcode.com/2015/day/5 "see puzzle")
|
5 | [:star: :star:](https://adventofcode.com/2018/day/5 "see puzzle")
|
||||||
6 | [:star: :star:](https://adventofcode.com/2015/day/6 "see puzzle")
|
6 | [:star: :star:](https://adventofcode.com/2018/day/6 "see puzzle")
|
||||||
7 | [:star: :star:](https://adventofcode.com/2015/day/7 "see puzzle")
|
7 | [:star: :star:](https://adventofcode.com/2018/day/7 "see puzzle")
|
||||||
8 | [:star: :star:](https://adventofcode.com/2015/day/8 "see puzzle")
|
8 | [:star: :star:](https://adventofcode.com/2018/day/8 "see puzzle")
|
||||||
9 | [:star: :star:](https://adventofcode.com/2015/day/9 "see puzzle")
|
9 | [:star: :star:](https://adventofcode.com/2018/day/9 "see puzzle")
|
||||||
10 | [:star: :star:](https://adventofcode.com/2015/day/10 "see puzzle")
|
10 | [:star: :star:](https://adventofcode.com/2018/day/10 "see puzzle")
|
||||||
11 | [:star: :star:](https://adventofcode.com/2015/day/11 "see puzzle")
|
11 | [:star: :star:](https://adventofcode.com/2018/day/11 "see puzzle")
|
||||||
12 | [:star: :star:](https://adventofcode.com/2015/day/12 "see puzzle")
|
12 | [:star: :star:](https://adventofcode.com/2018/day/12 "see puzzle")
|
||||||
|
|
||||||
# Languages Used
|
# Languages Used
|
||||||
### Python
|
### Python
|
||||||
|
@ -33,5 +33,5 @@
|
||||||
12 | :star: :star:
|
12 | :star: :star:
|
||||||
|
|
||||||
### Java (Processing)
|
### Java (Processing)
|
||||||
1 | :star: :star:
|
10 | :star: :star:
|
||||||
--: | :--
|
--: | :--
|
||||||
|
|
1
2019/02/input.txt
Normal file
1
2019/02/input.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,6,1,19,1,5,19,23,2,6,23,27,1,27,5,31,2,9,31,35,1,5,35,39,2,6,39,43,2,6,43,47,1,5,47,51,2,9,51,55,1,5,55,59,1,10,59,63,1,63,6,67,1,9,67,71,1,71,6,75,1,75,13,79,2,79,13,83,2,9,83,87,1,87,5,91,1,9,91,95,2,10,95,99,1,5,99,103,1,103,9,107,1,13,107,111,2,111,10,115,1,115,5,119,2,13,119,123,1,9,123,127,1,5,127,131,2,131,6,135,1,135,5,139,1,139,6,143,1,143,6,147,1,2,147,151,1,151,5,0,99,2,14,0,0
|
19
2019/02/part1.js
Normal file
19
2019/02/part1.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
const text = fs.readFileSync("./input.txt", "utf-8");
|
||||||
|
|
||||||
|
let memory = text.split(',').map(opcode => parseInt(opcode));
|
||||||
|
|
||||||
|
memory[1] = 12;
|
||||||
|
memory[2] = 2;
|
||||||
|
|
||||||
|
for (let i = 0; i < memory.length; i+=4) {
|
||||||
|
if (memory[i] == 1) {
|
||||||
|
memory[memory[i+3]] = memory[memory[i+1]] + memory[memory[i+2]];
|
||||||
|
} else if (memory[i] == 2) {
|
||||||
|
memory[memory[i+3]] = memory[memory[i+1]] * memory[memory[i+2]];
|
||||||
|
} else if (memory[i] == 99) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(memory[0]);
|
27
2019/02/part2.js
Normal file
27
2019/02/part2.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
const text = fs.readFileSync("./input.txt", "utf-8");
|
||||||
|
|
||||||
|
for (let noun = 0; noun < text.split(',').length; noun++){
|
||||||
|
|
||||||
|
for (let verb = 0; verb < text.split(',').length; verb++){
|
||||||
|
|
||||||
|
let memory = text.split(',').map(opcode => parseInt(opcode));
|
||||||
|
|
||||||
|
memory[1] = noun;
|
||||||
|
memory[2] = verb;
|
||||||
|
|
||||||
|
for (let i = 0; i < memory.length; i+=4) {
|
||||||
|
if (memory[i] == 1) {
|
||||||
|
memory[memory[i+3]] = memory[memory[i+1]] + memory[memory[i+2]];
|
||||||
|
} else if (memory[i] == 2) {
|
||||||
|
memory[memory[i+3]] = memory[memory[i+1]] * memory[memory[i+2]];
|
||||||
|
} else if (memory[i] == 99) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memory[0] == 19690720){
|
||||||
|
console.log(noun, verb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
2019/README.md
Normal file
10
2019/README.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# [2019](https://adventofcode.com/2019 "2019 puzzle calendar")
|
||||||
|
1 | [:star: :star:](https://adventofcode.com/2019/day/1 "see puzzle")
|
||||||
|
--: | :--
|
||||||
|
2 | [:star: :star:](https://adventofcode.com/2019/day/2 "see puzzle")
|
||||||
|
|
||||||
|
# Languages Used
|
||||||
|
### Node JS
|
||||||
|
|
||||||
|
1 | :star: :star:
|
||||||
|
2 | :star: :star:
|
Loading…
Reference in a new issue