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?
- 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
- Puzzle | Connect 9 circles each arranged at center of a Matrix using 3 straight lines
- Program for Chocolate and Wrapper Puzzle
- Queries to count groups of N students possible having sum of ratings within given range
- Minimum increments required to make given matrix palindromic
- Check if it is possible to reach (X, Y) from (1, 0) by given steps
- Count ways to generate N-length array with 0s, 1s, and 2s such that sum of all adjacent pairwise products is K
- Remove nodes from Binary Tree such that sum of all remaining root-to-leaf paths is atleast K
- Longest subsequence having maximum GCD between any pair of distinct elements