Union
by Isai Damier, Android Engineer @ Google

#======================================================================
# Author: Isai Damier
# Title: Union
# Project: geekviewpoint
# Package: algorithms
#
# Statement:
#   Given two sets of bits, x and y, find their union.
#
# Sample Input:  0110101; 0101100
# Sample Output: 0111101
#
# Technical Details:
#   The union of two sets is the superset comprising all the elements
#   that appear in both sets. For example if s1 = [a,b,f,h,k] and
#   s2 = [b,c,d,f,h,position] then the union of s1 and s2 is
#   s1 U s2 = [a,b,c,d,f,h,position,k]. For two sets of bits the union
#   is simply the bitwise OR of the two sets. For example if x = 0110101
#   and y=0101100 then the union of x and y is x U y = 0111101.
#====================================================================== 
 def union( x, y ):
  return x | y
import unittest
from algorithms import bitwise as bits

class Test( unittest.TestCase ):

    def testUnion( self ):
        x = int( "0101100", 2 )
        y = int( "0110101", 2 )
        u = int( "0111101", 2 )
        self.assertEquals( u, bits.union( x, y ) )