Let me first describe my situation.
I have a list of Hex values, which are called BaseID. They are chosen such that logical OR between any number of them will give you a unique ID which is called FinalID. That is, my BaseID values are as follows.
BaseID = { 0x01, 0x02, 0x04, 0x08, 0x10, ... }
The critical point is that I don't know how many BaseIDs that I will have before I run the program (I do get a list of BaseIDs once I run the program as it is read from a file), or how many out of the total number of the BaseIDs will be used to create the FinalID. It is decided based upon other parts of my program. For example, following are two FinalIDs that I might have in my program.
FinalID = ( 0x01 | 0x04 ) = 0x05
FinalID = ( 0x02 | 0x04 | 0x10 ) = 0x16
Now, using OR operation for any number of BaseIDs is the easy part. My problem is, I need to extract from FinalID the BaseIDs used to create that FinalID. Since I've chosen BaseIDs such that they, once the OR operation is used, will ALWAYS give me a unique FinalID, I know that any given FinalID is created using a specific set of BaseIDs. Note that a FinalID can be created using only one BaseID too which is the equivalent of FinalID = ( BaseID | 0x00 ).
I know what I have to do to extract the BaseIDs used to create any particular FinalID; I have to get the complete list of BaseIDs involved, then use OR operator among each and every comibnation of elements to find out if which combination gives the particular FinalID.
However I'm finding it hard to convert this logic into a program. I am using C# with .NET 3.5 Framework. Any suggestions/ideas would be very much appreciated. A code sample is highly appreciated.
Thanks in advance!