generated from sigonasr2/CPlusPlusProjectTemplate
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.
89 lines
3.0 KiB
89 lines
3.0 KiB
#define OLC_PGE_APPLICATION
|
|
#include "pixelGameEngine.h"
|
|
#include "olcutils.h"
|
|
|
|
using namespace olc;
|
|
|
|
int main()
|
|
{
|
|
std::ifstream file("input");
|
|
std::vector<std::vector<int>> data;
|
|
while (file.good()){
|
|
std::string line;
|
|
std::getline(file,line);
|
|
if (line.length()>0){
|
|
std::cout<<line<<std::endl;
|
|
std::vector<int>rowData;
|
|
for (int i=0;i<line.length();i++){
|
|
rowData.push_back(line[i]);
|
|
}
|
|
data.push_back(rowData);
|
|
}
|
|
}
|
|
|
|
std::cout<<"=================="<<std::endl;
|
|
int maxScore=0;
|
|
for (int row=0;row<data.size();row++){
|
|
for (int col=0;col<data[row].size();col++){
|
|
std::cout<<"Checking score for ("<<col<<","<<row<<")"<<std::endl;
|
|
int score=1;
|
|
int target=data[row][col];
|
|
int diff=0;
|
|
for (int x=col-1;x>=0;x--){//Towards the left.
|
|
if (data[row][x]>=target){
|
|
int diff=col-x;
|
|
score*=diff;
|
|
std::cout<<" (Left Scan) Score increased by "<<diff<<" Score: "<<score<<std::endl;
|
|
goto next2;
|
|
}
|
|
}
|
|
diff=col;
|
|
score*=diff;
|
|
std::cout<<" (Left Scan) Score increased by "<<diff<<" Score: "<<score<<std::endl;
|
|
next2:
|
|
for (int x=col+1;x<data[row].size();x++){//Towards the right.
|
|
if (data[row][x]>=target){
|
|
int diff=x-col;
|
|
score*=diff;
|
|
std::cout<<" (Right Scan) Score increased by "<<diff<<" Score: "<<score<<std::endl;
|
|
goto next3;
|
|
}
|
|
}
|
|
diff=data[row].size()-col-1;
|
|
score*=diff;
|
|
std::cout<<" (Right Scan) Score increased by "<<diff<<" Score: "<<score<<std::endl;
|
|
next3:
|
|
for (int y=row-1;y>=0;y--){//Towards up.
|
|
if (data[y][col]>=target){
|
|
int diff=row-y;
|
|
score*=diff;
|
|
std::cout<<" (Up Scan) Score increased by "<<diff<<" Score: "<<score<<std::endl;
|
|
goto next4;
|
|
}
|
|
}
|
|
diff=row;
|
|
score*=diff;
|
|
std::cout<<" (Up Scan) Score increased by "<<diff<<" Score: "<<score<<std::endl;
|
|
next4:
|
|
for (int y=row+1;y<data.size();y++){//Towards down.
|
|
if (data[y][col]>=target){
|
|
int diff=y-row;
|
|
score*=diff;
|
|
std::cout<<" (Down Scan) Score increased by "<<diff<<" Score: "<<score<<std::endl;
|
|
goto next5;
|
|
}
|
|
}
|
|
diff=data.size()-row-1;
|
|
score*=diff;
|
|
std::cout<<" (Down Scan) Score increased by "<<diff<<" Score: "<<score<<std::endl;
|
|
next5:
|
|
if (score>=maxScore){
|
|
maxScore=score;
|
|
}
|
|
}
|
|
}
|
|
//Include edges.
|
|
std::cout<<"Max score:"<<maxScore<<std::endl;
|
|
|
|
return 0;
|
|
}
|
|
|