all possible permutations

john65442

New Member
Joined
Feb 25, 2011
Messages
13
Hi:-
i have 55 random small letters capital letters numbers and 3 symbols (they are - _ . )
[a-z],[A-Z],[0-9] and [-_.]
and i would like to get all possible permutations combination of them
in length of 2 digits
then 3 digits .....until ...32 digits length or may be more

i want to do each length alone one by one
first 2 digits then save the project
second 3 digits length then save the project
second 4 digits length then save the project ..........ext

Can anybody help me with the possible formula?

Thanks
 
Last edited:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Welcome to the board, John.

For a 4-character sequence selected from 55 symbols where order matters (permutations), there are over 9M arrangements. Where would you list them all, and what would you do when you had them?
 
Upvote 0
You have 65 characters total. (26+26+10+3 = 65)

If you want to generate all permutations with 32 digits, that's...
9.49827123012803E+53 permutations.

Way too many.

65 characters with just 5 digits is just shy of one billion permutations.
=PERMUT(65,5)
=991,186,560
 
Upvote 0
If you want to generate all permutations with 32 digits, that's...
9.49827123012803E+53 permutations.

I think this is more combinations that can fit in all the excel workbooks on all the computers in all the world.
It would also take a very long time to generate so many permutations (probably longer than you have left to live on this earth).

You'll need to make do without the permutations listed in Excel.

ξ
 
Upvote 0
i might do it for only 4-27 digits
you can always make vb start writing on a new column when
there is no space in the previous column
you can make vb start a new excel file and write in it also start writing on a new column when there is no space in the previous column .

i have searched the internet and found these two c++ codes :-

Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

/* type values used in init_char_set() function */
#define UPPER  1
#define LOWER  2
#define NUM    4
#define PUNCT  16
#define ALPHA  3
#define ALNUM  7
#define ALL    23
#define CUSTOM 32

/* pre defined char sets used in init_char_set() function */
#define UPPER_CHAR_SET "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LOWER_CHAR_SET "abcdefghijklmnopqrstuvwxyz"
#define DIGIT_CHAR_SET "0123456789"
#define PUNCT_CHAR_SET "~!@#$%^&*()_+{}|[]:\"<>?,./;'\\=-"

#define MAX_CHARS 150
#define MAX_GUESS 20

#ifndef NUL
#define NUL '\0'
#endif

/* Function Prototypes */
void permute_rep (const char *set, int n, int r);
char *init_char_set (short int type, char *custom);
int *init_perm_array (int len);
char *make_perm_string (int *perm, const char *set, int len, int print_flag);

/* Main Function, Drives the permute_rep() function */
int
main (void)
{
  char *set = NULL, custom[MAX_CHARS];
  int r;

  printf ("\nr-Permutation with repetitions.\n");

  printf ("Enter String Set To Permute: ");
  scanf ("%s", custom);

  printf ("\nLength Of Permutations (r): ");
  scanf ("%d", &r);

  set = init_char_set (CUSTOM, custom);
  printf ("\nPermutation Symbol set: \"%s\"\n", set);

  permute_rep (set, strlen (set), r);

  printf ("\nfinished\n");
  return 0;
}

/* Function Name : permute_rep
 * Parameters    : 
 *               @ (const char *) set : Pointer to the symbol sets to permute
 *               @ (int) n            : The length upto which the set would be used
 *               @ (int) r            : The length of the generated permutations
 * Return Value  : (void)
 * Description   : Generates all the Permutation with repetitions of length 'r' from the 'set' upto length 'n' .
 *                 Prints them in stdout.
 */
void
permute_rep (const char *set, int n, int r)
{
  int *perm;
  int i, j;

  perm = init_perm_array (r);
  while (perm[r] == 0)
    {
      for (j = 0; j < n; j++)
    {
      make_perm_string (perm, set, r, 1);
      perm[0]++;
    }
      perm[0]++;
      for (i = 0; i < r; i++)
    {
      if (perm[i] >= n)
        {
          perm[i] = 0;
          perm[i + 1]++;
        }
    }
    }
}


/* Function Name : init_char_set
 * Parameters    : 
 *               @ (short int) type   : The inbuilt type values to select character sets.
 *                                      'type' could be:
 *                                      1, 2, 4, 16, 32 or any of these values ORed. These are #defined
 *               @ (char *) custom    : Pointer to a custom symbol set to initialize. type should be 32 in,
 *                                      else this pointer is ignored.
 * Return Value  : (char *)           : Returns a pointer to the initialized character set
 * Description   : Allocates and initializes a pointer with a string of symbols to be permuted, and returns it
 */
char *
init_char_set (short int type, char *custom)
{
  char upper[] = UPPER_CHAR_SET;
  char lower[] = LOWER_CHAR_SET;
  char num[] = DIGIT_CHAR_SET;
  char punct[] = PUNCT_CHAR_SET;
  char *set;

  set = (char *) malloc (sizeof (char) * MAX_CHARS);

  if (type & UPPER)
    {
      strcat (set, upper);
    }
  if (type & LOWER)
    {
      strcat (set, lower);
    }
  if (type & NUM)
    {
      strcat (set, num);
    }
  if (type & PUNCT)
    {
      strcat (set, punct);
    }
  /* Remove redundant elements from custom string and build set. If input set is "hello"
   * then it will be reduced to "helo"
   */
  if (type & CUSTOM)
    {
      int i, j, k, n = strlen (custom), flag;
      for (i = 0, k = 0; i < n; i++)
    {
      for (flag = 0, j = 0; j < k; j++)
        {
          if (custom[i] == set[j])
        {
          flag = 1;
          break;
        }
        }
      if (flag == 0)
        {
          set[k] = custom[i];
          k++;
        }
    }
    }
  return set;
}

/* Function Name : init_perm_array
 * Parameters    : 
 *               @ (int) len          : The length of the array
 * Return Value  : (int *)            : A pointer to the allocated permutation array
 * Description   : Allocates and initializes with 0 an array, which is used for generating 'r' base numbers
 */
int *
init_perm_array (int len)
{
  int *perm;
  perm = (int *) calloc (len + 1, sizeof (int));
  return perm;
}

/* Function Name : make_perm_string
 * Parameters    : 
 *               @ (int *) perm       : Pointer to the current permutation count state
 *               @ (const char *) set : Pointer to the symbol set to be permuted
 *               @ (int) len          : The length of permutation
 *               @ (int) print_state  : A flag. If true prints the permutation in stdout, else does not.
 * Return Value  : (char *)           : A pointer to the string representing the permutation
 * Description   : Returns a pointer to a string representing the permutation of the symbols
 *                 from the 'set' represented by 'perm' state. This simply labels each position count of 'perm'
 *                 with the symbols from 'set' makes a string and returns it.
 *                 It also prints the string if 'print_state' is true.
 */
char *
make_perm_string (int *perm, const char *set, int len, int print_state)
{
  char *perm_str;
  int i, j;

  perm_str = (char *) malloc (sizeof (char) * (len + 1));

  for (i = len - 1, j = 0; i >= 0; i--, j++)
    {
      perm_str[j] = set[*(perm + i)];
    }
  perm_str[j] = NUL;

  if (print_state)
    printf ("%s\n", perm_str);

  return perm_str;
}

and

Code:
#include <stdio.h>
#include <stdlib.h>

#define MAX_NUM 100

//
//  A single call to permut(k, n) will produce (n - k + 1)!
//  permutations consisting of the integers:
//
//               r[1] ... r[k-1] ... r[k] ... r[n]
//  
//  In the output, the first r[1]...r[k-1] numbers will not
//  change.  The r[k]...r[n] numbers will be permiated.  An
//  initial call of permut(1, n) will produce the full n!
//  permutations of these n numbers.
//
//

void permut(int k, int n, int *nums)
{
  int i, j, tmp;

  /* when k > n we are done and should print */
  if (k <= n) 
  {

    for (i = k; i <= n; i++) 
    {

      /** 
        *  each element i is promoted to the kth place while the rest
        *  of the items from k to i-1 are shifted to make room with
        *  a ripple-shift operation.
        *
        **/
      tmp = nums[i];
      for (j = i; j > k; j--) 
      {
	nums[j] = nums[j-1];
      }
      nums[k] = tmp;

      /* recurse on k+1 to n */
      permut(k + 1, n, &(nums[0]));

      for (j = k; j < i; j++) 
      {
        nums[j] = nums[j+1];
      }
      nums[i] = tmp;
    }
  } 
  else 
  {
    for (i = 1; i <= n; i++) 
    {
      printf("%d ", nums[i]);
    }
    printf("\n");
  }
}

int main(void) 
{
  int iCount;
  int rgNums[MAX_NUM];
  int i;

  printf("Enter n: ");
  scanf("%d", &iCount);


  /* create a workspace of numbers in their respective places */
  for (i = 1; i <= iCount; i++)
  {
    rgNum[i] = i;
  }

  printf("Permutations:\n");
  permut(1, iCount, rgNum);
}
</pre>


does anybody knows how to use them

thanks.
 
Upvote 0
Your C++ code won't run in Excel VBA. But it doesn't matter.
With 27 digits you still have an impossibly large number of permutations:
=PERMUT(65,27)
1.57E+46
(15,769,204,460,090,400,000,000,000,000,000,000,000,000,000,000)

Numbers this large really can't even be comprehended - this is something on the level of the number of atoms in the entire planet earth. You don't realize it yet but what you are trying to do is impossible.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top