Esempio n. 1
0
void Solve()
{
  if(n % 3 != 0)
  {
    answer = false;
    return;
  }
  answer = tryToSolve(d1, d2)
    || tryToSolve(d1, -d2)
    || tryToSolve(-d1, d2)
    || tryToSolve(-d1, -d2);
}
Esempio n. 2
0
void taskGraphArray::depositData(taskGraphSolver *data) {
  // Someone sent me data back.
  DepsData[DepsReceived++] = data;

  // Now that we got that data try and solve the problem
  tryToSolve();
}
Esempio n. 3
0
/*
 * Now define the taskGraphArray that actually handles doing all that work.
 */
taskGraphArray::taskGraphArray(
	CkVec<CkArrayIndex> deps,
	taskGraphSolver *data,
	CkCallback returnResults
) : Waiting() {
  // Set some state variables
  ReturnResults = returnResults;
  Self = data;
  isSolved = false;

  // Save everything I need to know about
  DepsCount = deps.length();
  DepsData = new taskGraphSolver*[DepsCount];
  DepsReceived = 0;

  // Ask everyone I depend on for their data
  CProxy_taskGraphArray neighbor(thisArrayID);
  for ( int i = 0 ; i < DepsCount ; i++ ) {
    neighbor(deps[i]).requestData(thisIndexMax);
  }

  // If we're waiting on nothing we're solved
  tryToSolve();
}