```Hi,

that is very interesting and I hadn't even considered using bits. Know
operations ?

If you would care to elaborate more on your example, that might help
me understand it better. Perhaps explaining what each line is doing? I
sort of get the idea, but I would like to understand the internals of
HOW it is doing it -  in case I might want/need to modify  the
example.

I think what I don't understand the most, is the 2nd line

(val & (2 << pos)) ? 'N' : 'C

(inbetween the  DEF and END)   Where is it defining the maximum
number of letters to use in the generated combination, for example? Or
perhaps the example didn't really cover all that and I'm mistaken.

Thank you for your assistance so far,
-Zach

On 13 Feb 2010 19:08:43 GMT, Seebs <usenet-nospam / seebs.net> wrote:

>On 2010-02-13, Zach Bartels <no / spam.com> wrote:
>> I think I can work out the program itself.   But I am looking for a
>> quick and easy way to generate every possible 5 digit combination of
>> the letters " C" and "N"  so I have the database I need to compare
>> each 5 frame segment.
>
>That sounds like five bits.
>
>Consider, then, using bit operations.  Imagine that you have numbers from
>0 to 31.  Each number must have a unique pattern of bits, and a total of
>five bits.  So...
>	0	00000	CCCCC
>	1	00001	CCCCN
>	2	00010	CCCNC
>	3	00011	CCCNN
>	...
>	31	11111	NNNNN
>
>The question is, how do we turn a number into a set of binary digits?  One
>way would be:
>	def letter(val, pos)
>	  (val & (2 << pos)) ? 'N' : 'C'
>	end
>
>So that:
>	letter(16, 0) => 'C'
>	letter(16, 1) => 'C'
>	letter(16, 2) => 'C'
>	letter(16, 3) => 'C'
>	letter(16, 4) => 'N'
>
>So 16 => NCCCC.
>
>-s

```