Commit 93f2d66f authored by Mikkel Wienberg Madsen's avatar Mikkel Wienberg Madsen 👀
Browse files

Impl. Max subset

parent 441d454a
......@@ -5,6 +5,7 @@ import (
"sync"
"github.com/google/uuid"
"github.com/gonum/stat/combin"
)
type Whitelist map[uuid.UUID]pedersen.Proof
......@@ -60,6 +61,26 @@ func (j *Judge) GoodIds() []uuid.UUID {
return good
}
func MaxSubset(t int, superset [][]uuid.UUID) []uuid.UUID {
n := len(superset)
combis := combin.Combinations(t, n)
subsets := make([][]uuid.UUID, len(combis), n)
for i, ls := range combis {
sets := [][]uuid.UUID{}
for _, i := range ls {
sets = append(sets, superset[i])
}
subsets[i] = Intersection(sets)
}
max := 0
for i := 0; i < len(subsets); i++ {
if len(subsets[i]) > max {
max = i
}
}
return subsets[max]
}
func Intersection(superset [][]uuid.UUID) []uuid.UUID {
section := make(map[uuid.UUID]int, len(superset[0]))
for _, set := range superset {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment