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

Function CodeTable

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

Source from the content-addressed store, hash-verified

110}
111
112func CodeTable(perm [base]byte) int {
113 var index [base]byte
114 for i, v := range perm {
115 index[v] = byte(i)
116 }
117
118 r := 0
119 for min := byte(0); min < base-1; min++ {
120 z := 0
121 for _, v := range perm[:index[min]] {
122 if v > min {
123 z++
124 }
125 }
126 r += z * fact[min]
127 }
128 return r
129}
130
131func CodeTable2(perm [base]byte) int {
132 var index [base]byte

Callers 2

checkFunction · 0.85
BenchmarkTableFunction · 0.85

Calls

no outgoing calls

Tested by 2

checkFunction · 0.68
BenchmarkTableFunction · 0.68