Finished Day 2 Part 2
This commit is contained in:
@@ -10,6 +10,7 @@ int main()
|
||||
|
||||
int horizontal = 0;
|
||||
int vertical = 0;
|
||||
int aim = 0;
|
||||
|
||||
if(!input.is_open())
|
||||
{
|
||||
@@ -23,14 +24,17 @@ int main()
|
||||
if (movement == "forward")
|
||||
{
|
||||
horizontal += stoi(line.substr(line.find(" ")));
|
||||
vertical += aim * stoi(line.substr(line.find(" ")));
|
||||
}
|
||||
else if (movement == "up")
|
||||
{
|
||||
vertical -= stoi(line.substr(line.find(" ")));
|
||||
aim -= stoi(line.substr(line.find(" ")));
|
||||
}
|
||||
else
|
||||
{
|
||||
vertical += stoi(line.substr(line.find(" ")));
|
||||
aim += stoi(line.substr(line.find(" ")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user