# Sum over permuted indices

Consider this rank 6 tensor: $g_{ab}g_{cd}g_{ef}$.

Now I'd like to have a code to sum over all possible $6!$ permutations of the six indices with some coefficient $f[i]$, where $1 \leq i \leq 720$... the output should be something like:

f[1]g[[a,b]]g[[c,d]]g[[e,f]] + f[2]g[[a,f]]g[[c,d]]g[[e,b]] +..other 718 terms..

Any help would be greatly appreciated.. Thank you!

In:

Clear[a, b, c, d, e, f, h, xss, g, p]
xss = Permutations[{a, b, c, d, e, f}, {6}] // Map[Partition[#, 2] &]
p[n_, ps_] := h[n] Times @@ Map[Part[g, Sequence @@ #] &, ps]
ys = MapThread[p, {Range@Length@xss, xss}] // Quiet
ys // Total


Out:

You can use MapIndexed for this task:

func[{a_, b_, c_, d_, e_, f_}, {n_}] := ff[n] g[a, b] g[c, d] g[e, f]
Total@MapIndexed[func, Permutations[{a, b, c, d, e, f}]]