diff --git a/comsoc/Approval.go b/comsoc/Approval.go index 4450607b23ce3ca5c8c8ab224635c8300a8da32b..e6f3c5ed5da1a0a933b396081f93d4d0e5a89bca 100644 --- a/comsoc/Approval.go +++ b/comsoc/Approval.go @@ -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 }