Day 6/solution2.cpp
// Returns -1 if the configuration hasn't been seen yet and a positive integer
//  with the number of cycles between both appearances in the other case
1 if the configuration hasn't been seen yet and a positive integer
with the number of cycles between both appearances in the other case
1 if the configuration hasn ' t been seen yet and a positive integer with the number of cycles between both appearances in the other case
int CheckConfiguration(vector<int> v, map<string, int> & configurations, int num_reallocations) {
  string str = "";
  for (int i = 0; i<v.size(); i++) {
    str += " " + to_string(v[i]);
  }
  cout << str << endl;
  if (configurations.count(str) > 0) {
    return num_reallocations - configurations[str];
  } else {
    configurations.insert(pair<string, int> (str, num_reallocations));
    return -1;
  }
}
int CheckConfiguration ( vector < int > v , map < string , int > & configurations , int num_reallocations ) { string str = " " ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { str += " " + to_string ( v [ i ] ) ; } cout << str << endl ; if ( configurations . count ( str ) > 0 ) { return num_reallocations - configurations [ str ] ; } else { configurations . insert ( pair < string , int > ( str , num_reallocations ) ) ; return -1 ; } }
Returns -1 if the configuration hasn't been seen yet and a positive integer
with the number of cycles between both appearances in the other case
Returns - 1 if the configuration hasn ' t been seen yet and a positive integer with the number of cycles between both appearances in the other case