1

I created a program to solve crossword puzzle given 6 words with 7-letter each and the program will calculate how many total solutions it may have.

In this 3x3 grid, the constraints I set is for every 2nd, 4th, and 6th letter of a word that has the same letter and index as the other word, it can be matched to form a crossword. The 'A','B','C','D','E','F' indicate the row and column in the grid.

This example shows all the even letters are 'E'. The words are BEDEMEN, PETERED, BEMETED, LEVELED, LEVERED, and MESELED. Here is the picture for references: crossword puzzle solver picture

The total combinations that I got are 720 solutions or total possible combinations. The problem is this number might not be correct since I'm using a relational language to interpret and create a knowledge base to calculate the solutions.

I read a few sources in the StackExchange such as (source) but I can't really understand the concepts.

How do I calculate the possible combinations of words without having duplicate solutions so that I can double check with my program by using the formula?

Any helps will be much appreciated.

Bram28
  • 100,612
  • 6
  • 70
  • 118

1 Answers1

0

OK, so if I understand you correctly: it's a given that all the letters at the intersections are $E$'s, and it's a given that you need to use each of the $6$ words you have exactly once, and you want to know how many solutions there are, right?

If so, then the answer is indeed $720$: Since there are $6$ different positions for each of the $6$ words, you have $6$ positions for the first word to go, leaving $5$ positions for the next word, etc. So, you get

$$6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1 = 6! = 720$$

possibilities

Bram28
  • 100,612
  • 6
  • 70
  • 118
  • Great explanation! I'm wondering if the letters at the intersections are any letters and the same constraints are being applied (for eg. METEPAS, LEVELED, BEDERAL, PETERED, BEMEDAL, PAJAMAS. These 6 words has 24 solutions), how do I count the total possible solutions? –  Mar 08 '18 at 05:52
  • @LouisJuliendo Well, I would start with PAJAMAS: that one clearly needs to be either in the third row or third column, so two options there. Then, there are $3!=6$ ways to have the other three words with an A intersect with PAJAMAS, and finally you have $2$ ways to place the last two words. Total: $2 \cdot 6 \cdot 2=24$ – Bram28 Mar 08 '18 at 11:53
  • I am still unsure when to use ⋅ and when to use factorial. How about these 2 examples, the first example (LEVELED, LEVELER, LEVERED, MERISES, MEBOSES, MERINOS) gives me 324 solutions and the second example (LEVELED, LEVELER, LEVERED, MERITED, MEIOSES, MERINOS) gives me 12 solutions. I am not sure whether it's my code problem or not but they are supposed to produce the same output as the intersections are the same. Can you explain more on this? –  Mar 08 '18 at 12:49
  • @LouisJuliendo first one: you have one O, so MERINOS goes in row or column 2, and MEBOSES crosses with it in colum or row 3 respectively, so $2$ options there for placing those two. But that also forces MERISES to cross with MERINOS in column or row 2 respectively, so we're still at $2$ options for those three words. The last three can be put in in any way, so $3!$ options there, for a total of $12$ possibilities .... not $324$; you initely did something wrong there. And you're right, the second one is isomorphic to the first one, so you also get $12$ options there, so that one was correct! – Bram28 Mar 08 '18 at 12:58
  • My bad. I have figured out what's wrong with my code logic. And yes, both will result in 12 solutions. Thanks for the explanation! –  Mar 08 '18 at 13:16