Modified code for compatibility with python2.5 by explicitly defining
combinations function from itertools.