Solving Combination Puzzle in C++ - How Many Possible Combinations?

  • Thread starter badluckbrian
  • Start date
  • Tags
    Combination
In summary, the conversation discusses a C++ program being written to solve a puzzle with nine distinct squares in a 3x3 grid. The number of possible combinations is determined by first assigning the tiles to positions in the grid and then orienting each tile. The total number of combinations is estimated to be under 10^11.
  • #1
badluckbrian
1
0
I'm writing a C++ program to brute-force solve a puzzle, but in order to determine the number of iterations the loop of the program should have (in order to exhaust all possible solutions) I need to know how many possible combinations there are. This isn't homework, I was just intrigued on how to do it.

The puzzle has nine distinct squares which are to be arranged in a 3x3 grid, like one face of a Rubik's cube; any piece can go in any place. However, each piece, being a square, can be rotated in its place to produce a different solution (each edge of the square has a unique "piece" on it that must pair with other edges).

9^9^4 yielded a number that seemed way too big, and 9*9*4 seemed too small. I tried researching the formula, but since I have found every way possible through both high school and college to avoid math, it was lost on me.

tl;dr: how many possible combinations are there for a puzzle like this

http://www.google.com/imgres?imgurl...=pF7iT5ahLc_16gGmtbUI&ved=0CH8Q9QEwBg&dur=630


Thanks to anyone who can give me some help.
 
Mathematics news on Phys.org
  • #2
Break it into two parts: first, how many ways are there of assigning the tiles to positions in the 3x3 grid? (For simplicity, don't worry about symmetries.)
Having assigned the tiles to positions, how many ways are there of orienting each tile?
The 10 numbers obtained above are independent of each other, so multiply them together.
You should get a number a bit under 10^11.
 

FAQ: Solving Combination Puzzle in C++ - How Many Possible Combinations?

What is a combination puzzle?

A combination puzzle is a type of puzzle that requires the player to arrange a set of objects or symbols in a specific order to reach a desired outcome or solution. It typically involves a set of rules or restrictions that must be followed in order to find the correct combination.

Why is it important to solve combination puzzles in C++?

Solving combination puzzles in C++ allows for efficient and accurate calculations of all possible combinations. This is especially useful for puzzles with a large number of elements or symbols, as it would be time-consuming and prone to error to solve manually.

How do you approach solving a combination puzzle in C++?

The first step in solving a combination puzzle in C++ is to determine the number of elements or symbols involved and the restrictions or rules for arranging them. Then, a systematic approach can be used to generate and test all possible combinations until the correct solution is found.

How do you calculate the number of possible combinations in a puzzle?

The number of possible combinations in a puzzle can be calculated using the formula n! / (r! * (n-r)!), where n is the total number of elements or symbols and r is the number of elements used in each combination. This is known as the combination formula.

Are there any shortcuts or tricks for solving combination puzzles in C++?

While there may be some strategies or patterns that can be used to solve specific combination puzzles, there is no universal shortcut or trick for solving them all. The most efficient approach is to use a systematic method of generating and testing all possible combinations until the correct solution is found.

Back
Top