Permutation handling code implemented

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2, Sig, Sigo 2 years ago
parent c011e1fe45
commit 1ee858ae8b
  1. BIN
      C++ProjectTemplate
  2. 45
      main.cpp
  3. 2
      sig

Binary file not shown.

@ -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;

2
sig

@ -3,7 +3,7 @@ export AUTO_UPDATE=true
source utils/define.sh source utils/define.sh
define PROJECT_NAME "C++ProjectTemplate" define PROJECT_NAME "C++ProjectTemplate"
define CUSTOM_PARAMS "-std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -lpulse -lpulse-simple -I/usr/include/lua5.3" define CUSTOM_PARAMS "-std=c++17 -lX11 -lpthread -lpng -lstdc++fs -I/usr/include/lua5.3"
define LANGUAGE "C++" define LANGUAGE "C++"
source utils/main.sh source utils/main.sh

Loading…
Cancel
Save