#include #include #include using namespace std; struct Command { string direction; int distance; }; int main() { cout << "Advent of Code 2021 - Day 2 Part 1" << endl; int x, y = 0; ifstream filein("input"); vector inputCommands; for(string line; getline(filein, line);) { int space = line.find(" "); inputCommands.push_back(Command {line.substr(0, space), stoi(line.substr(space+1))}); } for(Command cmd : inputCommands) { if(cmd.direction == "forward") { x += cmd.distance; } else if (cmd.direction == "down") { y += cmd.distance; } else if(cmd.direction == "up") { y -= cmd.distance; } else { cout << "Uh I shouldn't get here in the for cmd loop" << endl; } } cout << x * y << endl; return 0; }