|
|
@ -1,8 +1,31 @@ |
|
|
|
#define OLC_PGE_APPLICATION |
|
|
|
#include <vector> |
|
|
|
#include "pixelGameEngine.h" |
|
|
|
#include <string> |
|
|
|
#include "olcutils.h" |
|
|
|
#include <map> |
|
|
|
|
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
#include <math.h> |
|
|
|
|
|
|
|
#include <fstream> |
|
|
|
|
|
|
|
|
|
|
|
using namespace olc; |
|
|
|
void printArr(std::vector<std::string> a, int n){ |
|
|
|
|
|
|
|
for (int i=0;i<n;i++){ |
|
|
|
|
|
|
|
std::cout<<a[i]<<" "; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::cout<<std::endl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void permutation(std::vector<std::string> a,int size, int n){ |
|
|
|
|
|
|
|
if (size==1){ |
|
|
|
|
|
|
|
printArr(a,n); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i=0;i<size;i++){ |
|
|
|
|
|
|
|
permutation(a,size-1,n); |
|
|
|
|
|
|
|
if (size&1){ |
|
|
|
|
|
|
|
swap(a[0],a[size-1]); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
swap(a[i],a[size-i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct Room{ |
|
|
|
struct Room{ |
|
|
|
std::vector<std::string>connections; |
|
|
|
std::vector<std::string>connections; |
|
|
@ -89,6 +112,7 @@ void explore(std::string currentRoom,std::map<std::string,bool>visitedvalves,int |
|
|
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
int main() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
std::vector<std::string>targetRooms; |
|
|
|
std::ifstream file("input"); |
|
|
|
std::ifstream file("input"); |
|
|
|
while (file.good()){ |
|
|
|
while (file.good()){ |
|
|
|
std::string line; |
|
|
|
std::string line; |
|
|
@ -103,6 +127,9 @@ int main() |
|
|
|
Room newRoom; |
|
|
|
Room newRoom; |
|
|
|
newRoom.name=valveName; |
|
|
|
newRoom.name=valveName; |
|
|
|
newRoom.flowValue=flowRate; |
|
|
|
newRoom.flowValue=flowRate; |
|
|
|
|
|
|
|
if (flowRate>0){ |
|
|
|
|
|
|
|
targetRooms.push_back(valveName); |
|
|
|
|
|
|
|
} |
|
|
|
while (marker!=std::string::npos){ |
|
|
|
while (marker!=std::string::npos){ |
|
|
|
std::string roomName=line.substr(marker-2,2); |
|
|
|
std::string roomName=line.substr(marker-2,2); |
|
|
|
std::cout<<"Connection w/"<<roomName<<" found"<<std::endl; |
|
|
|
std::cout<<"Connection w/"<<roomName<<" found"<<std::endl; |
|
|
@ -129,16 +156,8 @@ int main() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int i=0; |
|
|
|
permutation(targetRooms,targetRooms.size(),targetRooms.size()); |
|
|
|
for (std::map<std::string,Room>::iterator it=rooms.begin();it!=rooms.end();++it){ |
|
|
|
|
|
|
|
int j=0; |
|
|
|
|
|
|
|
for (std::map<std::string,Room>::iterator it2=rooms.begin();it2!=rooms.end();++it2){ |
|
|
|
|
|
|
|
if (j>=i){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|