home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!stanford.edu!nntp.Stanford.EDU!Ramon.M.Felciano
- From: felciano@summit.stanford.edu (Ramon M. Felciano)
- Subject: (Q) Need bit manipulation algorithm
- Message-ID: <1993Jan6.022430.19469@leland.Stanford.EDU>
- X-Posted-From: InterNews1.0b3@nntp.stanford.edu
- Sender: ?@leland.Stanford.EDU
- Organization: Stanford University Medical Media and Information
- Technologies
- Date: Wed, 6 Jan 93 02:24:30 GMT
- Xdisclaimer: No attempt was made to authenticate the sender's name.
- Lines: 44
-
-
- Happy New Year, all!
-
- I've got an interesting bit-manipulation problem for you. I need to
- know how to match a given bit pattern into a stored array of patterns.
- In particular, I need to come up with a "fuzzy match" if no exact one
- is found.
-
- For example, I want to match 00110101 into the following array:
-
- 1. 00000000
- 2. 00000010
- 3. 01000100
- 4. 00110101
- 5. 00001110
- 6. 00010110
- 7. 00101010
- 8. 00011000
- 9. 00000110
- 10. 00010010
-
- A simple loop will match it with #4.
-
- If I want to match 00110110, there is no exact match. In this case,
- I want it to return #6, which is only 1 bit off. If #6 weren't there,
- I would want it to return #9, which is 2 bits off, then #10, which is
- also 2 bits off, then #2 (1 bit off), then #1 (default)
-
- So: I need an algorithm that will find a consistent fuzzy match by
- subtracting bits. It needs to deal with ambiguities like #9 and #10.
- Thus if two matches have 90% of the bits in common, I need both of
- them back, one after the other (the order doesn't matter).
-
- Any ideas?
-
- Thanks!
-
- Ramon
-
- +----------------------------------------------------------------+
- | Ramon M. Felciano felciano@summit.stanford.edu |
- | Associate Director, SUMMIT (415) 723-9688 |
- | Stanford University Medical Media and Information Technologies |
- +----------------------------------------------------------------+
-