From c4a3b7f48532de2b65f920f4d0ad70f0d8936204 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 22 Sep 2023 05:18:04 -0500 Subject: [PATCH] Working on sub-problem smart implementation. File reading and structure preparation. --- .../ChallengeLeaguePointSolver.vcxproj | 6 +- ...ChallengeLeaguePointSolver.vcxproj.filters | 2 +- ...ChallengeLeaguePointSolver_BruteForce.old} | 0 .../ChampionsLeaguePointSolver.cpp | 81 +++++++++++++++++++ 4 files changed, 85 insertions(+), 4 deletions(-) rename ChallengeLeaguePointSolver/{ChallengeLeaguePointSolver.cpp => ChallengeLeaguePointSolver_BruteForce.old} (100%) create mode 100644 ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp diff --git a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj index be27c57..13070c9 100644 --- a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj +++ b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj @@ -18,6 +18,9 @@ x64 + + + 16.0 Win32Proj @@ -126,9 +129,6 @@ true - - - diff --git a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj.filters b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj.filters index 9bf4caf..8a937aa 100644 --- a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj.filters +++ b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files diff --git a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver_BruteForce.old similarity index 100% rename from ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp rename to ChallengeLeaguePointSolver/ChallengeLeaguePointSolver_BruteForce.old diff --git a/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp b/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp new file mode 100644 index 0000000..a50e269 --- /dev/null +++ b/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include + +std::string slurp(std::ifstream& in) { + std::ostringstream sstr; + sstr << in.rdbuf(); + return sstr.str(); +} + +struct ScoreData{ + int difficulty=0; + std::string song; + int totalEX=0; + int ex1=0,ex2=0,ex3=0; + std::string str()const{ + return "["+std::to_string(difficulty)+"] "+song+": "+std::to_string(totalEX)+" total, "+" EX1: "+std::to_string(ex1)+" EX2: "+std::to_string(ex2)+" EX3: "+std::to_string(ex3); + } + friend std::ostream&operator<<(std::ostream&os,const ScoreData&data){ + os<dataA,dataB; + std::vector>player1Score,player2Score,player3Score; + std::ifstream file("team.csv"); + std::string line; + //First two lines are garbage data. + std::getline(file,line); + std::getline(file,line); + for(int i=0;i<12;i++){ + std::getline(file,line); + int marker=0; + ScoreData dat{ + stoi(GetNext(marker,line)), + GetNext(marker,line), + stoi(GetNext(marker,line)), + stoi(GetNext(marker,line)), + stoi(GetNext(marker,line)), + stoi(GetNext(marker,line))}; + player1Score.emplace_back(std::pair{dat.ex1,0}); + player2Score.emplace_back(std::pair{dat.ex2,0}); + player3Score.emplace_back(std::pair{dat.ex3,0}); + dataA.emplace_back(dat); + } + //Two more lines of garbage data. + std::getline(file,line); + std::getline(file,line); + for(int i=0;i<12;i++){ + std::getline(file,line); + int marker=0; + ScoreData dat{ + stoi(GetNext(marker,line)), + GetNext(marker,line), + stoi(GetNext(marker,line)), + stoi(GetNext(marker,line)), + stoi(GetNext(marker,line)), + stoi(GetNext(marker,line))}; + player1Score[i].second=dat.ex1; + player2Score[i].second=dat.ex2; + player3Score[i].second=dat.ex3; + dataB.emplace_back(dat); + } + std::cout<<"File Contents:"<