From b466c6989f2c8f915e5c0ad77e0123dcc53e408e Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 22 Sep 2023 06:23:59 -0500 Subject: [PATCH] Complete, split into sub-problems so the program doesn't take a day to run. --- .../ChampionsLeaguePointSolver.cpp | 184 +++++++++++++++++- 1 file changed, 183 insertions(+), 1 deletion(-) diff --git a/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp b/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp index a50e269..961f072 100644 --- a/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp +++ b/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp @@ -3,6 +3,7 @@ #include #include #include +#include std::string slurp(std::ifstream& in) { std::ostringstream sstr; @@ -30,10 +31,25 @@ std::string GetNext(int&marker,std::string str){ return str.substr(originalMarker,marker-1); }; +struct TestCase{ + int p1Amt,p2Amt,p3Amt; +}; + +struct SongCombinations{ + std::vector>p1; //Index to song followed by EX of song. + std::vector>p2; + std::vector>p3; + std::setp1Picked; + std::setp2Picked; + std::setp3Picked; + int totalEX=0; + int remainingA,remainingB,remainingC; +}; + int main(){ std::vectordataA,dataB; std::vector>player1Score,player2Score,player3Score; - std::ifstream file("team.csv"); + std::ifstream file("team2.csv"); std::string line; //First two lines are garbage data. std::getline(file,line); @@ -78,4 +94,170 @@ int main(){ } } std::cout<<"==================="<cases; + for(int i=0;i<5;i++){ + for(int j=0;j<5;j++){ + for(int k=0;k<5;k++){ + if(i+j+k==6){ + cases.emplace_back(TestCase{i,j,k}); + } + } + } + } + + auto ChooseSong = [](SongCombinations&combinations,std::vector&dat,int index){ + if(combinations.remainingA>0&&combinations.p1Picked.count(index)==0){ + combinations.remainingA--; + combinations.totalEX+=dat[index].ex1; + combinations.p1.emplace_back(std::pair{index,dat[index].ex1}); + combinations.p1Picked.insert(index); + }else + if(combinations.remainingB>0&&combinations.p2Picked.count(index)==0){ + combinations.remainingB--; + combinations.totalEX+=dat[index].ex2; + combinations.p2.emplace_back(std::pair{index,dat[index].ex2}); + combinations.p2Picked.insert(index); + }else + if(combinations.remainingC>0&&combinations.p3Picked.count(index)==0){ + combinations.remainingC--; + combinations.totalEX+=dat[index].ex3; + combinations.p3.emplace_back(std::pair{index,dat[index].ex3}); + combinations.p3Picked.insert(index); + } + }; + + std::vector bestComboA,bestComboB; + int caseInd=0; + for(TestCase&_case:cases){ + bestComboA.push_back({}); + bestComboA[caseInd].remainingA=_case.p1Amt; + bestComboA[caseInd].remainingB=_case.p2Amt; + bestComboA[caseInd].remainingC=_case.p3Amt; + for(int i=0;i<12;i++){ + SongCombinations c1=bestComboA[caseInd]; + ChooseSong(c1,dataA,i); + for(int j=0;j<12;j++){ + SongCombinations c2=c1; + ChooseSong(c2,dataA,j); + for(int k=0;k<12;k++){ + SongCombinations c3=c2; + ChooseSong(c3,dataA,k); + for(int l=0;l<12;l++){ + SongCombinations c4=c3; + ChooseSong(c4,dataA,l); + for(int m=0;m<12;m++){ + SongCombinations c5=c4; + ChooseSong(c5,dataA,m); + for(int n=0;n<12;n++){ + SongCombinations c6=c5; + ChooseSong(c6,dataA,n); + if(bestComboA[caseInd].totalEX&p1:bestComboA[caseInd].p1){ + std::cout<<"P1["<&p2:bestComboA[caseInd].p2){ + std::cout<<"P2["<&p3:bestComboA[caseInd].p3){ + std::cout<<"P3["<&p1:bestComboB[caseInd].p1){ + std::cout<<"P1["<&p2:bestComboB[caseInd].p2){ + std::cout<<"P2["<&p3:bestComboB[caseInd].p3){ + std::cout<<"P3["<highestEX&&A.p1Picked.size()+B.p1Picked.size()==4&&A.p2Picked.size()+B.p2Picked.size()==4&&A.p3Picked.size()+B.p3Picked.size()==4){ + highestEX=A.totalEX+B.totalEX; + picked1=A; + picked2=B; + std::cout<<"New Best Song Combinations found for Final Picks - Total EX: "<&p1:picked1.p1){ + std::cout<<"P1["<&p2:picked1.p2){ + std::cout<<"P2["<&p3:picked1.p3){ + std::cout<<"P3["<&p1:picked2.p1){ + std::cout<<"P1["<&p2:picked2.p2){ + std::cout<<"P2["<&p3:picked2.p3){ + std::cout<<"P3["<