-
Notifications
You must be signed in to change notification settings - Fork 0
/
day2.cpp
58 lines (48 loc) · 1.16 KB
/
day2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
int main() {
std::string line;
//open the file (?)
std::ifstream myfile ("D:/c++/adventofcode/files/day2.txt");
std::vector<int> program;
if (myfile.is_open()) {
getline(myfile,line);
//create vector of input numbers out of string
//separate numbers by comma
program = vectorCreator(line);
//change values of vector at pos 1 and 2
//0-99 inclusive for both
std::cout << program[0] << std::endl;
for(int i=0; i<100; ++i) {
for(int j=0; j<100; ++j) {
program[1] = i;
program[2] = j;
//run computer
intCode(program);
//if desired result
if (program[0] == 19690720) {
goto endloop;
}
else {
//reset memory
program = vectorCreator(line);
}
}
}
//first part
// program[1] = 12;
// program[2] = 2;
// //run intcode
// intCode(program);
}
//print value, close file
endloop:
std::cout << 100*program[1] + program[2] << std::endl;
myfile.close();
//print value at pos 0 after intCode program runs
std::cout << program[0] << " " << program[1] << " " << program[2] << std::endl;
return 0;
}