MCPcopy Create free account
hub / github.com/egonelbre/exp / CodeCopy

Function CodeCopy

permutation/code.go:55–70  ·  view source on GitHub ↗
(perm [base]byte)

Source from the content-addressed store, hash-verified

53func Code(perm [base]byte) int { return CodeCopy(perm) }
54
55func CodeCopy(perm [base]byte) int {
56 r := 0
57 for min := byte(0); min < base-1; min++ {
58 z := 0
59 n := base - min
60 for i, v := range perm[:n] {
61 if v == min {
62 z = i
63 break
64 }
65 }
66 copy(perm[z:], perm[z+1:n])
67 r += z * fact[min]
68 }
69 return r
70}
71
72func CodeCopyBit(perm [base]byte) int {
73 return codebit(uint64(PackNybbleUnroll(perm)))

Callers 3

CodeFunction · 0.85
checkFunction · 0.85
BenchmarkCopyFunction · 0.85

Calls

no outgoing calls

Tested by 2

checkFunction · 0.68
BenchmarkCopyFunction · 0.68