Skip to content
Snippets Groups Projects
majority.go 353 B
Newer Older
Antoine Kryus's avatar
Antoine Kryus committed
package comsoc

func MajoritySWF(p Profile) (count Count, err error) {
Mohamed Fall's avatar
Mohamed Fall committed
	count = make(map[Alternative]int)
Mohamed Fall's avatar
Mohamed Fall committed
	for _, alts := range p {
		count[alts[0]] += 1
Mohamed Fall's avatar
Mohamed Fall committed
	} // 0-votes alternatives are not included
	return count, nil
Antoine Kryus's avatar
Antoine Kryus committed
}

Mohamed Fall's avatar
Mohamed Fall committed
func MajoritySCF(p Profile) (bestAlts []Alternative, err error) {
	count, erreur := MajoritySWF(p)
	return maxCount(count), erreur
Antoine Kryus's avatar
Antoine Kryus committed
}