Advertisement
rfmonk

collection_counter_arithmetic.py

Jan 9th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import collections
  5.  
  6. c1 = collections.Counter(['a', 'b', 'c', 'a', 'b', 'b'])
  7. c2 = collections.Counter('alphabet')
  8.  
  9. print 'C1:', c1
  10. print 'C2:', c2
  11.  
  12. print '\nCombined counts:'
  13. print c1 - c2
  14.  
  15. print '\nIntersection (taking positive minimums):'
  16. print c1 & c2
  17.  
  18. print '\nUnion (taking maximums):'
  19. print c1 | c2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement