Skip to content
Snippets Groups Projects
Commit 7ce9c60f authored by Balthazar Wilson's avatar Balthazar Wilson
Browse files

fix: approval

parent 596e8ee9
No related branches found
No related tags found
No related merge requests found
...@@ -4,18 +4,21 @@ package comsoc ...@@ -4,18 +4,21 @@ package comsoc
// thresholds est un slice d'entiers strictement positifs // thresholds est un slice d'entiers strictement positifs
func ApprovalSWF(p Profile, thresholds []int) (count Count, err error) { func ApprovalSWF(p Profile, thresholds []int) (count Count, err error) {
count = make(Count) count = make(Count)
for _, pref := range p { alts := make([]Alternative, 0)
for index, alt := range pref { for i := 1; i <= len(p[0]); i++ {
count[alt] += thresholds[len(thresholds)-1-index] alts = append(alts, Alternative(i))
}
err = checkProfileAlternative(p, alts)
for index, alt := range p {
for i := 0; i < thresholds[index]; i++ {
count[alt[i]] += 1
} }
} }
return count, nil return
} }
func ApprovalSCF(p Profile, thresholds []int) (bestAlts []Alternative, err error) { func ApprovalSCF(p Profile, thresholds []int) (bestAlts []Alternative, err error) {
count, err := ApprovalSWF(p, thresholds) alts, err := ApprovalSWF(p, thresholds)
if err != nil { bestAlts = maxCount(alts)
return nil, err return
}
return maxCount(count), nil
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment