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_Day3/main.cpp

50 lines
1.5 KiB

2 years ago
#define OLC_PGE_APPLICATION
#include "pixelGameEngine.h"
#include "olcutils.h"
using namespace olc;
int main()
2 years ago
{
std::ifstream file("input");
int sum=0;
while (file.good()) {
std::string line;
std::string line2;
std::string line3;
std::getline(file,line);
std::getline(file,line2);
std::getline(file,line3);
if (line.length()>0) {
std::cout<<"=========="<<std::endl;
std::cout<<line<<std::endl;
std::cout<<line2<<std::endl;
std::cout<<line3<<std::endl;
for (int i=0;i<line.length();i++) {
for (int j=0;j<line2.length();j++) {
for (int k=0;k<line3.length();k++) {
if (line[i]==line2[j]&&line2[j]==line3[k]&&line[i]==line3[k]) {
if (line[i]>='A'&&line[i]<='Z') {
int prio=27+line[i]-'A';
sum+=prio;
std::cout<<"Prio "<<prio<<" for "<<line[i]<<std::endl;
} else {
int prio=1+line[i]-'a';
sum+=prio;
std::cout<<"Prio "<<prio<<" for "<<line[i]<<std::endl;
}
goto outer;
}
}
}
}
outer:;
2 years ago
}
}
2 years ago
std::cout<<"Sum: "<<sum<<std::endl;
2 years ago
return 0;
}