Why not create a hash using 'Ob2code' as the key that points to an array storing the '0b1's that are associated with a particular 'Ob2code'?
I am reasonably sure that this would be an O(n) proceedure, since you would have to run though the list only once to make the proper assignments...not sure if really solves the problem, though.