Re: generating unique letter combinations

From: Ian Woods (newspub2_at_wuggyNOCAPS.org)
Date: 11/10/03


Date: Mon, 10 Nov 2003 16:24:23 +0000 (UTC)


"Jason" <jason.carney1@btinternet.com> wrote in
news:boodpd$e3a$1@hercules.btinternet.com:

> hi,
>
> I want to be able to generate all unique combinations of a string, for
> example, abc = abc, ab, ac, bc, a, b, c for any length string. Is
> there an algorithm that is well known and efficient for this or should
> i just make something up?
>
> thanks in advance.

It's called counting. Instead of counting numbers, you count letters
instead. If your character set has all of the letters contiguous (like
ASCII), you can merely count in an array so that each value is between 0
and the number of letters, and then add the base value of the first letter.

If you do it on paper by counting, what I'm talking about should be clear -
though I'd suggest only using an alphabet of 4 characters rather than 26.

Ian Woods



Relevant Pages

  • Re: string to number
    ... First, I'll point out that the string "abc" doesn't convert to 656667, ... The string "ABC" is what converts to 656667. ... treated as upper case ones) from letters to their concatenated ASCII ...
    (microsoft.public.vb.enterprise)
  • Re: Math with letters
    ... Const A As Integer = 0 ... I want it to be able to take the string (which contains the letters AB) and convert that text into a form where it recognizes the letters as constants and not a string. ... If they enter in ABC it to do the math of 0*1*2 and output that, not output the text ABC again. ...
    (microsoft.public.dotnet.languages.vb)
  • Math with letters
    ... Const A As Integer = 0 ... I want it to be able to take the string (which contains the letters AB) and convert that text into a form where it recognizes the letters as constants and not a string. ... If they enter in ABC it to do the math of 0*1*2 and output that, not output the text ABC again. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Help a beginner - simple lowercase to uppercase and so on function
    ... can understand everything but it should take shape with more practice ... it compiles and returns uppercase letters ... in this string!" ... to compile on both. ...
    (comp.lang.c)
  • Re: Data Validation, Identify Duplicates and Limit imput
    ... The first 3 characters must be UPPERCASE letters A to Z. ... ABC 1234 ... error message if a duplicate reference is entered however I need to add ...
    (microsoft.public.excel.worksheet.functions)