From 7ce9c60f3fe3ae1bd6eb502b2209954f529cc8b6 Mon Sep 17 00:00:00 2001 From: Balthazar Wilson <balthazar.wilson@etu.utc.fr> Date: Sat, 14 Oct 2023 15:38:33 +0200 Subject: [PATCH] fix: approval --- comsoc/Approval.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/comsoc/Approval.go b/comsoc/Approval.go index 4450607..e6f3c5e 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 } -- GitLab