enumerate all possible combinations

Jasmine Elm

This is more of a thought exercise than a real problem.

I have 24 switches. The switches are arranged in pairs; 1 and 13, 2 and 14, and so on. Each switch has two possible values; off and on. If one switch in the pair is in the on position, the other must be in the off position. There will always be more than two switches in the on position, but never more than ten.

Is there an elegant way to list the possible combinations?

rossum

Each pair of switches has three possible states: off off; off on; on off. To generate all possible overall states, start counting in base 3 from 000 ... 000 to 222 ... 222 where there are 12 base 3 digits, each digit representing a pair of switches.

Putting in the limits on the numbers of on and off switches is more complex, and will probably have to be done by explicit counting, unless someone comes up with a better idea. You must have at least two non-zero digits and at most ten non-zero digits.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PHP: Enumerate All Possible Combinations in Multi-dimensional Array

From Dev

How to enumerate all combinations in a matrix in R?

From Dev

Enumerate all possible decisions rules

From Dev

Generate all possible combinations

From Dev

All Possible Bit Combinations

From Dev

Finding all possible combinations

From Dev

All Possible Combinations in Grid

From Dev

Finding all possible combinations

From Dev

All Possible Combinations in Grid

From Dev

fastest way in python to enumerate all combinations and return the index

From Dev

fastest way in python to enumerate all combinations and return the index

From Dev

Create strings with all possible combinations

From Dev

All possible combinations in array - recursion?

From Dev

Generate all possible combinations in Python

From Dev

Generating all possible combinations of strings

From Dev

List all possible combinations for a vector

From Dev

Iterating through all possible combinations

From Dev

Generating all possible binary combinations

From Dev

How to generate all possible combinations?

From Dev

Generate All Possible Combinations - Java

From Dev

Generate all possible polynomial combinations

From Dev

All possible combinations in array - recursion?

From Dev

Generate all possible combinations in Python

From Dev

All possible combinations of strings MATLAB

From Dev

Rank all possible groupby combinations

From Dev

Iterating through all possible combinations

From Dev

Instantiating all possible combinations of enums

From Dev

List all possible combinations for a vector

From Dev

Couple the data in all possible combinations