code: def random_combination_with_replacement(iterable, r):
      "Random selection from itertools.combinations_with_replacement(iterable, r)"
      pool = tuple(iterable)
      n = len(pool)
      indices = sorted(random.randrange(n) for i in xrange(r))
      return tuple(pool[i] for i in indicesf random_combination_with_replacement(iterable, r):
      "Random selection from itertools.combinations_with_replacement(iterable, r)"
      pool = tuple(iterable)
      n = len(pool)
      indices = sorted(random.randrange(n) for i in xrange(r))
      return tuple(pool[i] for i in indices)
docs: Random selection from itertools.combinations_with_replacement(iterable, r)