Forked from
Gabrielle Van De Vijver / IA04binôme2A
72 commits behind the upstream repository.
-
Gabrielle Van De Vijver authoredGabrielle Van De Vijver authored
Borda.go 609 B
package comsoc
import("fmt")
func BordaSWF(p Profile) (count Count, err error){
count = make(Count)
nAlts := len(p[0])
for _, row := range p{
for i:=0; i<nAlts;i++{
count[row[i]]+=nAlts-1-i
}
}
return count,nil
}
func BordaSCF(p Profile) (bestAlts []Alternative, err error) {
count, err := BordaSWF(p)
if err != nil {
return nil, err
}
return maxCount(count), nil
}
func Test_borda(){
profil := GenerateProfile(3,5)
fmt.Println("Profil :", profil)
count,_ := BordaSWF(profil)
fmt.Println("Décompte :", count)
winners,_ := BordaSCF(profil)
fmt.Println("Vainqueur(s) :", winners)
}