code: def factor_list_to_map(factors):
          
          ret = {}
          for k, g in itertools.groupby(factors):
              ret[k] = len(list(g))
          return ret
docs: Factor list to map factor -> power
          :param factors:
          :return: