A 10 x 10 Crossword grid is provided, along with a set of words (or names of places) which need to be filled into the grid. The cells in the grid are initially, either + signs or – signs. Cells marked with a ‘+’ have to be left as they are. Cells marked with a ‘-‘ need to be filled up with an appropriate character.
You are also given an array of words that need to be filled in Crossword grid.
Input : +++++++++- -++++++++- -------++- -++++++++- -++++++++- -++++----- ------+++- -++++++++- +--------- ++++++++++ Output : +++++++++C P++++++++H HISTORY++E Y++++++++M S++++++++I I++++MATHS CIVICS+++T S++++++++R +GEOGRAPHY ++++++++++
The approach behind this is to recursively check for each word in the vertical position and in the horizontal position. Then fill the word in the matrix that can be the best fit in the corresponding position of the grid, then update the crossword grid by filling the gap with that word.
1 way to solve the puzzle *J******** *H******** *A****P*** *R#***U#** *K****N*** *H****J*** *A****A*** *N*MUMBAI* *D******** ***MIZORAM Number of ways to fill the grid is 1
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Solve the Logical Expression given by string
- How to solve problems related to Number-Digits using Recursion?
- Program for Chocolate and Wrapper Puzzle
- Programming puzzle (Assign value without any control statement)
- Egg Dropping Puzzle with 2 Eggs and K Floors
- Eggs dropping puzzle (Binomial Coefficient and Binary Search Solution)
- A Sum Array Puzzle
- Maximum score assigned to a subsequence of numerically consecutive and distinct array elements
- Maximum subsequence sum possible by multiplying each element by its index
- Number from a range [L, R] having Kth minimum cost of conversion to 1 by given operations
- Count permutations of given array that generates the same Binary Search Tree (BST)
- Check if every vertex triplet in graph contains two vertices connected to third vertex
- Generate a combination of minimum coins that sums to a given value
- Remove all duplicate adjacent characters from a string using Stack
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.