Working on sub-problem smart implementation. File reading and structure preparation.

master
sigonasr2 1 year ago
parent 8b35a680bf
commit c4a3b7f485
  1. 6
      ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj
  2. 2
      ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.vcxproj.filters
  3. 0
      ChallengeLeaguePointSolver/ChallengeLeaguePointSolver_BruteForce.old
  4. 81
      ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp

@ -18,6 +18,9 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ChampionsLeaguePointSolver.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
@ -126,9 +129,6 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ChallengeLeaguePointSolver.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ChallengeLeaguePointSolver.cpp">
<ClCompile Include="ChampionsLeaguePointSolver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>

@ -0,0 +1,81 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
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<<data.str();
return os;
}
};
std::string GetNext(int&marker,std::string str){
int originalMarker=marker;
marker=str.find_first_of(',',originalMarker)+1;
return str.substr(originalMarker,marker-1);
};
int main(){
std::vector<ScoreData>dataA,dataB;
std::vector<std::pair<int,int>>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<int,int>{dat.ex1,0});
player2Score.emplace_back(std::pair<int,int>{dat.ex2,0});
player3Score.emplace_back(std::pair<int,int>{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:"<<std::endl<<std::endl;
for(auto&list:{dataA,dataB}){
for(auto&dat:list){
std::cout<<dat<<std::endl;
}
}
std::cout<<"==================="<<std::endl;
}
Loading…
Cancel
Save