Determining Winning Combinations of Parties with >50% Votes

In summary, the conversation discusses the challenge of determining all possible combinations of parties that have more than 50% of the votes in a coalition government. The solution is to use a groovy script that calculates all possible combinations and their corresponding vote percentages. This eliminates the need for manual calculation and provides over 500 winning combinations.
  • #1
Ryan_m_b
Staff Emeritus
Science Advisor
5,963
721
This is born out of musings around coalition governments that arise from the party with the most votes not achieving ≥50% of the votes (as opposed to emergency coalitions).

Taking the figures below how would one go about determining all the possible combinations of parties who combined have >50% of the votes without sitting down and working them out one by one?

Kid gloves please :redface: I haven't studied maths for the better part of a decade...

Parties / Percentage of votes

Pink / 21
Orange / 19
Brown / 16
Blue / 10
Green / 10
Tan / 8
Red / 5
Black / 4
Purple / 4
White / 3
 
Mathematics news on Phys.org
  • #2


Brute force my friend !
Here is a groovy script that answers your question:
Code:
def X=[Pink:21, Orange:19, Brown:16, Blue:10, Green:10, Tan:8, Red:5, Black:4, Purple:4, White:3]
def XS=X.keySet() as List
def N=XS.size()
def F; F={ ix,n ->
	def L0=[XS[ix]]
	if(n==1) return [L0]
	def L=[]
	for(def j=ix; j<N-1; j++) { 
		F(j+1, n-1).each{ L<<(L0+it) }
	}
	L
}
def OK=[:]
for(def i=0;i<N;i++) {
	for(def j=1;j<=N-i;j++) {
		def c=F(i,j)
		c.each{ 
			def s=0; it.each { s+=X[it]} 
			if(s>50) OK[it]=s 
		}
	}
}
OK.keySet().sort{x,y->OK[y]<=>OK[x]}.each{ println "$it: ${OK[it]}%" }
I don't post the result since there are 502 winning combinations going all the way from 51% up to 100% :smile:
 
  • #3


oli4 said:
Brute force my friend !
Here is a groovy script that answers your question:
I don't post the result since there are 502 winning combinations going all the way from 51% up to 100% :smile:
Wow thanks a lot! To be honest I'm not really sure how to work code lol but it's good to know that there's a relatively simple way to get it done. Thanks!
 

Related to Determining Winning Combinations of Parties with >50% Votes

What is the purpose of "Find Combos >50% Votes"?

The purpose of "Find Combos >50% Votes" is to identify combinations of two or more items that have received more than 50% of the total votes.

How does "Find Combos >50% Votes" work?

"Find Combos >50% Votes" works by analyzing voting data and determining which combinations have received more than 50% of the votes. It takes into account both the number of votes and the percentage of the total votes received by each item in the combination.

What types of data can be used with "Find Combos >50% Votes"?

"Find Combos >50% Votes" can be used with any type of data that includes voting information, such as survey results, election data, or market research data.

Can "Find Combos >50% Votes" be used for both small and large datasets?

Yes, "Find Combos >50% Votes" can be used for both small and large datasets. It is designed to be scalable and can handle a large amount of data.

How can the results from "Find Combos >50% Votes" be used?

The results from "Find Combos >50% Votes" can be used to identify popular combinations of items and inform decision making. For example, in an election, it can help identify the winning candidate or in market research, it can help identify the most popular product bundles.

Similar threads

  • General Math
Replies
2
Views
3K
Replies
5
Views
5K
  • Quantum Physics
Replies
1
Views
748
Replies
38
Views
4K
  • General Discussion
Replies
10
Views
2K
  • General Discussion
2
Replies
65
Views
8K
Replies
93
Views
9K
Back
Top