Brute force.

master
sigonasr2 1 year ago
parent a89a3cf4cf
commit 8b35a680bf
  1. 306
      ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp
  2. BIN
      ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.exe
  3. BIN
      ChallengeLeaguePointSolver/output.txt

@ -2,6 +2,7 @@
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
std::string slurp(std::ifstream& in) {
std::ostringstream sstr;
@ -76,80 +77,255 @@ int main(){
}
std::cout<<"==================="<<std::endl;
std::vector<Selection>bestSelections;
while(true){
int Aselections=6,Bselections=6;
Selection selection;
int totalEX=0;
int hash=0;
std::vector<int>randomChoice={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
for(int iSel=0;iSel<4;iSel++){
int arrInd=rand()%randomChoice.size();
int randSongIndex=randomChoice[arrInd];
randomChoice.erase(randomChoice.begin()+arrInd);
ScoreData*dataRef;
if(randSongIndex<12){
Aselections--;
dataRef=&dataA[randSongIndex];
Selection selection;
ScoreData*dataRef;
std::vector<int>sortedChoices={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
std::sort(sortedChoices.begin(),sortedChoices.end(),[&](int&val1,int&val2){
int ex1;
int ex2;
if(val1<12){
ex1=dataA[val1].totalEX;
}else{
Bselections--;
dataRef=&dataB[randSongIndex-12];
}
selection.selectedScore.push_back({0,randSongIndex});
selection.totalEX+=dataRef->ex1;
totalEX+=dataRef->ex1;
}
for(int iSel=0;iSel<4;iSel++){
int arrInd=rand()%randomChoice.size();
int randSongIndex=randomChoice[arrInd];
while(Aselections==0&&randSongIndex<12||Bselections==0&&randSongIndex>=12){
arrInd=rand()%randomChoice.size();
randSongIndex=randomChoice[arrInd];
ex1=dataB[val1-12].totalEX;
}
randomChoice.erase(randomChoice.begin()+arrInd);
ScoreData*dataRef;
if(randSongIndex<12){
Aselections--;
dataRef=&dataA[randSongIndex];
if(val2<12){
ex2=dataA[val2].totalEX;
}else{
Bselections--;
dataRef=&dataB[randSongIndex-12];
ex2=dataB[val2-12].totalEX;
}
selection.selectedScore.push_back({1,randSongIndex});
selection.totalEX+=dataRef->ex2;
totalEX+=dataRef->ex2;
return ex1>ex2;
});
for(int a1=0;a1<24;a1++){
int Aselections=6,Bselections=6;
selection.selectedScore.clear();
selection.totalEX=0;
std::vector<int>remainingChoices=sortedChoices;
int arrInd=a1;
if(Aselections==0&&remainingChoices[a1]<12||Bselections==0&&remainingChoices[a1]>=12)continue;
selection.selectedScore.push_back({0,remainingChoices[arrInd]});
if(remainingChoices[arrInd]<12){
Aselections--;
dataRef=&dataA[remainingChoices[arrInd]];
}else{
Bselections--;
dataRef=&dataB[remainingChoices[arrInd]-12];
}
for(int iSel=0;iSel<4;iSel++){
int arrInd=rand()%randomChoice.size();
int randSongIndex=randomChoice[arrInd];
while(Aselections==0&&randSongIndex<12||Bselections==0&&randSongIndex>=12){
arrInd=rand()%randomChoice.size();
randSongIndex=randomChoice[arrInd];
}
randomChoice.erase(randomChoice.begin()+arrInd);
ScoreData*dataRef;
if(randSongIndex<12){
Aselections--;
dataRef=&dataA[randSongIndex];
selection.totalEX+=dataRef->ex1;
remainingChoices.erase(remainingChoices.begin()+arrInd);
for(int a2=0;a2<23;a2++){
Selection selection2 = selection;
int Aselections2=Aselections,Bselections2=Bselections;
std::vector<int>remainingChoices2 = remainingChoices;
int arrInd=a2;
if(Aselections2==0&&remainingChoices2[a2]<12||Bselections2==0&&remainingChoices2[a2]>=12)continue;
selection2.selectedScore.push_back({0,remainingChoices2[arrInd]});
if(remainingChoices2[arrInd]<12){
Aselections2--;
dataRef=&dataA[remainingChoices2[arrInd]];
}else{
Bselections--;
dataRef=&dataB[randSongIndex-12];
Bselections2--;
dataRef=&dataB[remainingChoices2[arrInd]-12];
}
selection.selectedScore.push_back({2,randSongIndex});
selection.totalEX+=dataRef->ex3;
totalEX+=dataRef->ex3;
}
if(bestSelections.size()>0){
int bestEX=bestSelections.back().totalEX;
if(totalEX>bestEX){
std::cout<<"New best EX combination found: "+std::to_string(totalEX)+". Selections are:"<<std::endl<<"\t";
for(std::pair<int,int>&song:selection.selectedScore){
std::cout<<"P"<<song.first<<"|"<<song.second<<",";
selection2.totalEX+=dataRef->ex1;
remainingChoices2.erase(remainingChoices2.begin()+arrInd);
if(bestSelections.size()>0&&selection2.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*10)continue;
for(int a3=0;a3<22;a3++){
Selection selection3 = selection2;
std::vector<int>remainingChoices3 = remainingChoices2;
int Aselections3=Aselections2,Bselections3=Bselections2;
int arrInd=a3;
if(Aselections3==0&&remainingChoices3[a3]<12||Bselections3==0&&remainingChoices3[a3]>=12)continue;
selection3.selectedScore.push_back({0,remainingChoices3[arrInd]});
if(remainingChoices3[arrInd]<12){
Aselections3--;
dataRef=&dataA[remainingChoices3[arrInd]];
}else{
Bselections3--;
dataRef=&dataB[remainingChoices3[arrInd]-12];
}
selection3.totalEX+=dataRef->ex1;
remainingChoices3.erase(remainingChoices3.begin()+arrInd);
if(bestSelections.size()>0&&selection3.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*9)continue;
for(int a4=0;a4<21;a4++){
Selection selection4 = selection3;
std::vector<int>remainingChoices4 = remainingChoices3;
int Aselections4=Aselections3,Bselections4=Bselections3;
int arrInd=a4;
if(Aselections4==0&&remainingChoices4[a4]<12||Bselections4==0&&remainingChoices4[a4]>=12)continue;
selection4.selectedScore.push_back({0,remainingChoices4[arrInd]});
if(remainingChoices4[arrInd]<12){
Aselections4--;
dataRef=&dataA[remainingChoices4[arrInd]];
}else{
Bselections4--;
dataRef=&dataB[remainingChoices4[arrInd]-12];
}
selection4.totalEX+=dataRef->ex1;
remainingChoices4.erase(remainingChoices4.begin()+arrInd);
if(bestSelections.size()>0&&selection4.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*8)continue;
for(int b1=0;b1<20;b1++){
Selection selection5 = selection4;
std::vector<int>remainingChoices5 = remainingChoices4;
int Aselections5=Aselections4,Bselections5=Bselections4;
int arrInd=b1;
if(Aselections5==0&&remainingChoices5[b1]<12||Bselections5==0&&remainingChoices5[b1]>=12)continue;
selection5.selectedScore.push_back({1,remainingChoices5[arrInd]});
if(remainingChoices5[arrInd]<12){
Aselections5--;
dataRef=&dataA[remainingChoices5[arrInd]];
}else{
Bselections5--;
dataRef=&dataB[remainingChoices5[arrInd]-12];
}
selection5.totalEX+=dataRef->ex2;
remainingChoices5.erase(remainingChoices5.begin()+arrInd);
if(bestSelections.size()>0&&selection5.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*7)continue;
for(int b2=0;b2<19;b2++){
Selection selection6 = selection5;
std::vector<int>remainingChoices6 = remainingChoices5;
int Aselections6=Aselections5,Bselections6=Bselections5;
int arrInd=b2;
if(Aselections6==0&&remainingChoices6[b2]<12||Bselections6==0&&remainingChoices6[b2]>=12)continue;
selection6.selectedScore.push_back({1,remainingChoices6[arrInd]});
if(remainingChoices6[arrInd]<12){
Aselections6--;
dataRef=&dataA[remainingChoices6[arrInd]];
}else{
Bselections6--;
dataRef=&dataB[remainingChoices6[arrInd]-12];
}
selection6.totalEX+=dataRef->ex2;
remainingChoices6.erase(remainingChoices6.begin()+arrInd);
if(bestSelections.size()>0&&selection6.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*6)continue;
for(int b3=0;b3<18;b3++){
Selection selection7 = selection6;
std::vector<int>remainingChoices7 = remainingChoices6;
int Aselections7=Aselections6,Bselections7=Bselections6;
int arrInd=b3;
if(Aselections7==0&&remainingChoices7[b3]<12||Bselections7==0&&remainingChoices7[b3]>=12)continue;
selection7.selectedScore.push_back({1,remainingChoices7[arrInd]});
if(remainingChoices7[arrInd]<12){
Aselections7--;
dataRef=&dataA[remainingChoices7[arrInd]];
}else{
Bselections7--;
dataRef=&dataB[remainingChoices7[arrInd]-12];
}
selection7.totalEX+=dataRef->ex2;
remainingChoices7.erase(remainingChoices7.begin()+arrInd);
if(bestSelections.size()>0&&selection7.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*5)continue;
for(int b4=0;b4<17;b4++){
Selection selection8 = selection7;
std::vector<int>remainingChoices8 = remainingChoices7;
int Aselections8=Aselections7,Bselections8=Bselections7;
int arrInd=b4;
if(Aselections8==0&&remainingChoices8[b4]<12||Bselections8==0&&remainingChoices8[b4]>=12)continue;
selection8.selectedScore.push_back({1,remainingChoices8[arrInd]});
if(remainingChoices8[arrInd]<12){
Aselections8--;
dataRef=&dataA[remainingChoices8[arrInd]];
}else{
Bselections8--;
dataRef=&dataB[remainingChoices8[arrInd]-12];
}
selection8.totalEX+=dataRef->ex2;
remainingChoices8.erase(remainingChoices8.begin()+arrInd);
if(bestSelections.size()>0&&selection8.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*4)continue;
for(int c1=0;c1<16;c1++){
Selection selection9 = selection8;
std::vector<int>remainingChoices9 = remainingChoices8;
int Aselections9=Aselections8,Bselections9=Bselections8;
int arrInd=c1;
if(Aselections9==0&&remainingChoices9[c1]<12||Bselections9==0&&remainingChoices9[c1]>=12)continue;
selection9.selectedScore.push_back({2,remainingChoices9[arrInd]});
if(remainingChoices9[arrInd]<12){
Aselections9--;
dataRef=&dataA[remainingChoices9[arrInd]];
}else{
Bselections9--;
dataRef=&dataB[remainingChoices9[arrInd]-12];
}
selection9.totalEX+=dataRef->ex3;
remainingChoices9.erase(remainingChoices9.begin()+arrInd);
if(bestSelections.size()>0&&selection9.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*3)continue;
for(int c2=0;c2<15;c2++){
Selection selection10 = selection9;
std::vector<int>remainingChoices10 = remainingChoices9;
int Aselections10=Aselections9,Bselections10=Bselections9;
int arrInd=c2;
if(Aselections10==0&&remainingChoices10[c2]<12||Bselections10==0&&remainingChoices10[c2]>=12)continue;
selection10.selectedScore.push_back({2,remainingChoices10[arrInd]});
if(remainingChoices10[arrInd]<12){
Aselections10--;
dataRef=&dataA[remainingChoices10[arrInd]];
}else{
Bselections10--;
dataRef=&dataB[remainingChoices10[arrInd]-12];
}
selection10.totalEX+=dataRef->ex3;
remainingChoices10.erase(remainingChoices10.begin()+arrInd);
if(bestSelections.size()>0&&selection10.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*2)continue;
for(int c3=0;c3<14;c3++){
Selection selection11 = selection10;
std::vector<int>remainingChoices11 = remainingChoices10;
int Aselections11=Aselections10,Bselections11=Bselections10;
int arrInd=c3;
if(Aselections11==0&&remainingChoices11[c3]<12||Bselections11==0&&remainingChoices11[c3]>=12)continue;
selection11.selectedScore.push_back({2,remainingChoices11[arrInd]});
if(remainingChoices11[arrInd]<12){
Aselections11--;
dataRef=&dataA[remainingChoices11[arrInd]];
}else{
Bselections11--;
dataRef=&dataB[remainingChoices11[arrInd]-12];
}
selection11.totalEX+=dataRef->ex3;
remainingChoices11.erase(remainingChoices11.begin()+arrInd);
if(bestSelections.size()>0&&selection11.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX))continue;
for(int c4=0;c4<13;c4++){
Selection selection12 = selection11;
std::vector<int>remainingChoices12 = remainingChoices11;
int Aselections12=Aselections11,Bselections12=Bselections11;
int arrInd=c4;
if(Aselections12==0&&remainingChoices12[c4]<12||Bselections12==0&&remainingChoices12[c4]>=12)continue;
selection12.selectedScore.push_back({2,remainingChoices12[arrInd]});
if(remainingChoices12[arrInd]<12){
Aselections12--;
dataRef=&dataA[remainingChoices12[arrInd]];
}else{
Bselections12--;
dataRef=&dataB[remainingChoices12[arrInd]-12];
}
selection12.totalEX+=dataRef->ex3;
if(bestSelections.size()>0){
int bestEX=bestSelections.back().totalEX;
if(selection12.totalEX>bestEX){
std::cout<<"New best EX combination found: "+std::to_string(selection12.totalEX)+". Selections are:"<<std::endl<<"\t";
for(std::pair<int,int>&song:selection12.selectedScore){
std::cout<<"P"<<song.first<<"|"<<song.second<<",";
}
std::cout<<std::endl;
bestSelections.push_back(selection12);
}
}else{
bestSelections.push_back(selection12);
std::cout<<"New best EX combination found: "+std::to_string(selection12.totalEX)+". Selections are:"<<std::endl<<"\t";
for(std::pair<int,int>&song:selection12.selectedScore){
std::cout<<"P"<<song.first<<"|"<<song.second<<",";
}
std::cout<<std::endl;
}
}
}
}
}
}
}
}
}
}
std::cout<<std::endl;
bestSelections.push_back(selection);
}
}else{
bestSelections.push_back(selection);
}
}
std::cout<<"Done"<<std::endl;

Loading…
Cancel
Save