Skip to content
Snippets Groups Projects
Commit 60cc1c61 authored by Gabrielle Van De Vijver's avatar Gabrielle Van De Vijver
Browse files

Merge branch 'fix/approval' into 'main'

fix: approval

See merge request !4
parents 1ad3d16c 5c660c1e
No related branches found
No related tags found
1 merge request!4fix: approval
......@@ -4,18 +4,21 @@ package comsoc
// thresholds est un slice d'entiers strictement positifs
func ApprovalSWF(p Profile, thresholds []int) (count Count, err error) {
count = make(Count)
for _, pref := range p {
for index, alt := range pref {
count[alt] += thresholds[len(thresholds)-1-index]
alts := make([]Alternative, 0)
for i := 1; i <= len(p[0]); i++ {
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) {
count, err := ApprovalSWF(p, thresholds)
if err != nil {
return nil, err
}
return maxCount(count), nil
alts, err := ApprovalSWF(p, thresholds)
bestAlts = maxCount(alts)
return
}
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