You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AoC2022_Day21/main.cpp

41 lines
1.1 KiB

#define OLC_PGE_HEADLESS
#define OLC_PGE_APPLICATION
#include "pixelGameEngine.h"
using namespace olc;
struct Monkey{
int number=999999999;
std::string monkey1="";
std::string operation="";
std::string monkey2="";
};
int main()
{
std::map<std::string,Monkey>monkeys;
std::ifstream file("input");
while(file.good()){
std::string line;
std::getline(file,line);
if (line.length()>0){
Monkey m{999999999,"","",""};
std::string name=line.substr(0,4);
if (line.length()==17){
m.monkey1=line.substr(6,4);
m.operation=line.substr(11,1);
m.monkey2=line.substr(13,4);
} else {
m.number=std::atoi(line.substr(6,line.size()-6).c_str());
}
//std::cout<<line<<std::endl;
if (m.number!=999999999){
std::cout<<"Monkey "<<name<<": "<<m.number<<std::endl;
} else {
std::cout<<"Monkey "<<name<<": "<<m.monkey1<<" "<<m.operation<<" "<<m.monkey2<<std::endl;
}
}
}
return 0;
}