code.png
1.5 MB
Magnet Puzzle
We are given a set of bipolar magnets, each domo-shaped. The objective is to place magnet on an M * N board, which satisfies a set of conditions where both M and N are not odd.
The time complexity of the above solution is exponential and requires additional space for the recursion (call stack)
#Source_code
#Data_Structures
#Magnet_Puzzle
#130
We are given a set of bipolar magnets, each domo-shaped. The objective is to place magnet on an M * N board, which satisfies a set of conditions where both M and N are not odd.
The time complexity of the above solution is exponential and requires additional space for the recursion (call stack)
#Source_code
#Data_Structures
#Magnet_Puzzle
#130
Java
code.png
For instance, the following problem has the solution on its right.
Each 2 * 1 or 1 * 2 grid in the board can contain a magnet or empty. The blank entry will be indicated by X's, and the magnet will be represented by + and - (For the positive and negative end, respectively). The digits along the board's left and top sides represent the count of + squares in corresponding rows or columns. Similarly, those along the right and bottom show the total number of - signs in particular rows or columns. Rows and columns for which no number is mentioned can have any number of + or - signs. The puzzle solution must also satisfy the constraint that no two adjacent squares can have the same sight.
#Data_Structures
#Magnet_puzzle
#130
Each 2 * 1 or 1 * 2 grid in the board can contain a magnet or empty. The blank entry will be indicated by X's, and the magnet will be represented by + and - (For the positive and negative end, respectively). The digits along the board's left and top sides represent the count of + squares in corresponding rows or columns. Similarly, those along the right and bottom show the total number of - signs in particular rows or columns. Rows and columns for which no number is mentioned can have any number of + or - signs. The puzzle solution must also satisfy the constraint that no two adjacent squares can have the same sight.
#Data_Structures
#Magnet_puzzle
#130