On Sun, Jan 12, 2014 at 8:21 AM, Peter Otten <__pete...@web.de> wrote: > > OP: You'll get bonus points (from me, so they're pointless points, but > still) if you can solve this (including the fifth apocryphal test case) > using the collections.Counter class.
Hint: >>> print(Counter.__sub__.__doc__) Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) >>> product = Counter('t-shirt') >>> product - Counter('wsx0-=mttrhix') Counter() >>> product - Counter('wsx0-=mtrhix') Counter({'t': 1}) `Counter` has multiset methods for the operators +, -, & (intersection; min count), and | (union; max count). However, it doesn't implement the `issubset` or `issuperset` methods of `set`, nor the ordered comparisons (<, >, <=, >=) that depend on them. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor