So basically, in my government class, we are simulating a presidential election. Our grade comes from the presentation of our candidate, but as an added challenge our teacher has a running count of electoral votes garnered. How it works is like this:

  1. there are only 18 states amounting to 286 delegates, so 144 needed to win

  2. Candidates get a +1 'influence' in certain states (for example home state or somewhere they're popular) and -1, as do VP candidates.

  3. Some states (CA and TX) have a pre-existing leaning of up to 2 'influences'.

  4. You need to choose 4 issues you're against and 4 you're for, out of a list of 14. Each state has an issue they're against or for. As expected, being in agreement with a state nets you +1 in that state and disagreement nets you -1.

  5. If you have more influence in the state, you win it. If it's tied at 0, then the popular vote (the class) gets to decide)

I'm trying to lock up the nomination without even needing to get the popular votes, and I'm trying to figure out what software I could use to do this. I know excel and python 3 at a basic level, but I'm wondering if there's some other way to do it.

Here is an image of what I'm talking about (as you can see, I'm playing as the republicans here). Also, the for and against positions formulas link to here. Now, if I need to choose 4 issues to be for and against, I think that's 14 choose 4 times 10 choose 4, which gives me 210,210 possible combinations. Is there a way to run through all of these to see which will give me the highest Net Electoral Vote count with the lowest closeness factor? Obviously, I don't know my opponents topics yet, but I'd like to have the largest margin of error possible to prevent them from flipping states.

Thanks for any help. tips, advice or comments!

TL;DR: Political simulation, have to find best possible combination of issues to talk about out of 200,000+ possibilities, how do I run through them?


1 Answer 1


200000 is not a terribly large number, a brute force solution in Python would probably run in reasonable time. You'd have to implement a function that calculates your influences depending on your answers to the 14 issues and then just check all the possibilities. Python has some nice library functions that can help in the itertools package, but programming questions should better be asked on Stackoverflow.

A solution that is requires more learning to implement would writing down the problem as an Integer Linear Program and feeding it to a solver. That would probably scale much better than a naive brute force solution. It also sounds more sciency. But as I said, your problem instance is reasonably small.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.