1 of 3

Python 2.7 - 654B (600B without r-compability)

This is my first try at Codegolf, I hope it satisfies. I needed 2h. (But I'm still a beginner at Python)

Code:

def s(L):L.sort();return L
class B:
def p(self):return[[i]*self.L.count(i)for k,i in enumerate(self.L)if i!=self.L[k-1]]
def __sub__(self,o):return B([i for k in self.p()for i in k[:max(0,self.L.count(k[0])-o.L.count(k[0]))]])
def __mul__(self,o):return B(self.L*o)
def __div__(self,o):return B([i for k in self.p()for i in k[::o][:[-1,None][len(k)%o==0]]])
def c(self,o):return min([[self.L.count(i),0][self.L.count(i)<o.L.count(i)] for i in o.L])
def __eq__(self,o):return self.L==o.L


checks:

print B([1,2,2,3]) + B([1,2,4]) == B([1,1,2,2,2,3,4]) # Add

print B([1,2,2,4]) - B([1,2]) == B([2,4]) #Substract
print B([1,2,3])   - B([2,4]) == B([1,3]) #Substract

print B([1,2,3,3,4]) * 3 == B([1,1,1,2,2,2,3,3,3,3,3,3,4,4,4])#Multiply
print 2 * B([1,3]) == B([1,1,3,3])

print B([1,1,2,2,2])/2    == B([1,2]) #Divide
print B([1,2,2,3,3,3]) /3 == B([3])   #

print B([1,1,2,2,2,2,3,3,3]).c(B([1,2,3]))==2 #Contained n times

print B([3,2,1,2]) == B([1,2,2,3]) # Equal
print B([1,2,3])   == B([1,2,2,3]) # Unequal


Output:

True
True
True
True
True
True
True
True
True
False


I might try it a second time wit set as basis some time.