|
|
|
@ -1,8 +1,31 @@ |
|
|
|
|
#define OLC_PGE_APPLICATION |
|
|
|
|
#include "pixelGameEngine.h" |
|
|
|
|
#include "olcutils.h" |
|
|
|
|
#include <vector> |
|
|
|
|
#include <string> |
|
|
|
|
#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{ |
|
|
|
|
std::vector<std::string>connections; |
|
|
|
@ -89,6 +112,7 @@ void explore(std::string currentRoom,std::map<std::string,bool>visitedvalves,int |
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
|
{ |
|
|
|
|
std::vector<std::string>targetRooms; |
|
|
|
|
std::ifstream file("input"); |
|
|
|
|
while (file.good()){ |
|
|
|
|
std::string line; |
|
|
|
@ -103,6 +127,9 @@ int main() |
|
|
|
|
Room newRoom; |
|
|
|
|
newRoom.name=valveName; |
|
|
|
|
newRoom.flowValue=flowRate; |
|
|
|
|
if (flowRate>0){ |
|
|
|
|
targetRooms.push_back(valveName); |
|
|
|
|
} |
|
|
|
|
while (marker!=std::string::npos){ |
|
|
|
|
std::string roomName=line.substr(marker-2,2); |
|
|
|
|
std::cout<<"Connection w/"<<roomName<<" found"<<std::endl; |
|
|
|
@ -129,16 +156,8 @@ int main() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int i=0; |
|
|
|
|
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){ |
|
|
|
|
permutation(targetRooms,targetRooms.size(),targetRooms.size()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
i++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|