All Combinations

Hi,
how can i get all combinations
from 0x00,0x00,0x00,0x00,0x00,0x00 to 0xff,0xff,0xff,0xff,0xff,0xff ?

uchar default[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  for(int KeyA=0; KeyA < 16; KeyA++)
  {
    for(int CodeA=0; CodeA < 256; CodeA++)
    {
     default[KeyA]=CodeA;
    }
  }

So i dont get all combinations :frowning:

Even if you did one combination per clock cycle, 2128 combinations is going to take a few billion years to compute.

Edit: About 673,931,095,284,769,880,043,505 years, or about 49,013,170,566,165 times the age of the Universe

AWOL:
Maybe he has a quantum UNO.

ripper121:
Once you decide how many combinations you really need, you have two choices. A series of nested for loops that each count from 0-255, or count with a single number and extract each byte with bit-fiddling.

what is your goal?
generating all MAC addresses?

wrote this some years ago

//
//    FILE: perm1.pde
//  AUTHOR: Rob Tillaart
//    DATE: 2010-11-23
//
// PUPROSE: demo permutations
//
char permstring[12] = "123456789A";

void permutate(int n)
{  
  if (n==0) // end reached print the string
  {
    //for (int i = 0; i < strlen(permstring); i++)
    //    Serial.print(permstring[i]);
    //Serial.println();
    return;
  }

  for (int i = 0; i <n; i++) 
  {
    // swap
    char t = permstring[i];
    permstring[i] = permstring[n-1];
    permstring[n-1] = t;

    // permutate substrings
    permutate(n-1);

    // swap back
    t = permstring[i];
    permstring[i] = permstring[n-1];
    permstring[n-1] = t;
  }
}

void setup()
{
  Serial.begin(115200);
  unsigned long time = millis();
  permutate(strlen(permstring));
  time = millis() - time;
  Serial.print("TIME: ");
  Serial.println(time);
  while(1);
}

void loop()
{
}

takes less than a minute, 11 char takes 11 minutes, 12 -> 2 hours, 13 -> ~day, 14 -> 2 weeks, 15 -> half a year, 16 -> 8 years, 17 1.3 century, 18 -> 2 millenia, 19 -> period of modern man (~40.000 yrs) 20 -> 0.8 million years, 21 -> 16 million years, 22 -> 300 million years, 23 -> earths life, 24 -> beyond universe life.

AWOL:
Even if you did one combination per clock cycle, 2128 combinations is going to take a few billion years to compute.

Edit: About 673,931,095,284,769,880,043,505 years, or about 49,013,170,566,165 times the age of the Universe

He wants only to do 248 combinations. If one per usec => 9 years ?

thx

He wants only to do 248 combinations

So why a sixteen byte array?for(int KeyA=0; KeyA < 16; KeyA++)

There is a clear mismatch between his requirements and the code. Think [16] should be [6] . but that is my interpretation.

ripper121:
Hi,
how can i get all combinations
from 0x00,0x00,0x00,0x00,0x00,0x00 to 0xff,0xff,0xff,0xff,0xff,0xff ? <<<<<<< 6 BYTES

uchar default[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };    <<<<<<< ARRAY OF 16 BUT ONLY 6 INITIALIZED

for(int KeyA=0; KeyA < 16; KeyA++)
  {
    for(int CodeA=0; CodeA < 256; CodeA++)
    {
    default[KeyA]=CodeA;
    }
  }




So i dont get all combinations :(
<<<<<<< ARRAY OF 16 BUT ONLY 6 INITIALIZED

Assuming that's a global, all sixteen entries are initialised to zero.

I meant, initialized explicitly :blush: