what is the output for :
Code: Select all
3
1 1
+---+
| |
| |
| |
+---+
1 1
+---+
| * |
| * |
| * |
+---+
2 2
+---+---+
| | |
| |** |
| | * |
+---+---+
| | |
| | |
| | |
+---+---+
-titid-
Moderator: Board moderators
Code: Select all
3
1 1
+---+
| |
| |
| |
+---+
1 1
+---+
| * |
| * |
| * |
+---+
2 2
+---+---+
| | |
| |** |
| | * |
+---+---+
| | |
| | |
| | |
+---+---+
Code: Select all
+---+
| |
|** |
| * |
+---+
Code: Select all
1 1
+---+
| * |
| * |
| * |
+---+
Code: Select all
1 1
+---+
| |
|** |
| * |
+---+
Code: Select all
Number of solutions: 2
so the four solutions would be...whether one can turn the pieces in such a way that the patterns form a line connecting some edge of the top left square and some edge of the bottom right square of the board.
Code: Select all
+---+
| * |
|** |
| |
+---+
+---+
| * |
| **|
| |
+---+
+---+
| |
|** |
| * |
+---+
+---+
| |
| **|
| * |
+---+
In every step you can remember how you are rotated. There are four possible rotations. Let's denote them by numbers 0, 1, 2 and 3. After applying square A the rotation doesn't change. After applayng square B the rotation changes by +1 and -1 (mod 4). Then you move to the new position according to your new rotation.alzika wrote:How do I even attempt this problem? I know it is backtracking, and that part is rather easy, but I'm not sure how to handle the backtracking portion involving the rotations
Code: Select all
square A square B
*** **
*
You can remember in an array which squares the path is already crossing.alzika wrote:and keeping track
Don't just stop after you've found one path, but continue (by backtracking) to find all the paths.alzika wrote:as well as finding the NUMBER of solutions instead of just finding if there is a path at all.