algorithms and arduino

So, I have made a algorithm in c++ to run every possible combination on a masterlock combination lock. Here is the code so far, my goal is to display all the combinations in the serial monitor.

int count = 0;
void setup()
{
Serial.begin(9600);
Solve(0, 0, 0);
}
void Solve(int x, int y, int z)
{
if((x <= 39)&&(y <= 39)&&(z <= 39))
{
count = count + 1;
Serial.Print(count, DEC);
Serial.Print(“ “);
Serial.Print(x, DEC);
Serial.Print(“ “);
Serial.Print(y, DEC);
Serial.Print(“ “);
Serial.Print(z, DEC);
Serial.Println(“”);
if(x >= 0 && x < 39)
{
x = x + 1;
Solve(x, y, z);
}
else if(x >= 39 && y < 39)
{
x = 0;
y = y + 1;
Solve(x, y, z);
}
else if(x >= 39 && y >= 39 && z < 39)
{
x = 0;
y = 0;
z = z + 1;
Solve(x, y, z);
}
}
}

So, I have made a algorithm in c++ to run every possible combination on a masterlock combination lock. Here is the code so far, my goal is to display all the combinations in the serial monitor.

And . . . .? :cold_sweat:

You are calling the Solve() function recursively and the lines like

   Serial.Print(count, DEC);

won't compile so I suspect that you have some problems.

Oh ya, I guess I should have stated my problem! Oops. It will not compile and I was wondering why?

It will not compile and I was wondering why?

Look at Serial.print() - Arduino Reference for a clue.

And if that was not enough of a cluex4, note that c++ is case sensitive.

print needs to be lowercase

non recursive version:

unsigned long count = 0;

void setup()
{
  Serial.begin(9600);
  Solve();
}

void loop()
{
}

void Solve()
{
  for (int x = 0; x < 40; x++)
  {
    for (int y = 0; y < 40; y++)
    {
      for (int z = 0; z < 40; z++)
      {
        count++;
        Serial.print(count, DEC);
        Serial.print("\t");
        Serial.print(x, DEC);
        Serial.print("\t");
        Serial.print(y, DEC);
        Serial.print("\t");
        Serial.println(z, DEC);
      }
    }
  }
}

Even if you get it to compile, those recursive calls to Solve() are going to clobber the stack.