Problem 44711. Toads and Frogs Puzzle 2

On a two-dimensional board with 2n + 1 rows and 2n + 1 columns, all (2n + 1)^2 positions of the board, except the central one, are occupied by toads (T) and frogs (F), as follows.

In the first n rows, the first n + 1 positions are occupied by toads followed by n frogs. In row n + 1, the first n positions are occupied by toads followed by one vacant position (X) followed by n toads. In the last n rows, the first n positions are occupied by n toads followed by n + 1 frogs. For n = 3, this is depicted by the board to left below.

      T  T  T  T  F  F  F                  F  F  F  F  T  T  T
      T  T  T  T  F  F  F                  F  F  F  F  T  T  T
      T  T  T  T  F  F  F                  F  F  F  F  T  T  T
      T  T  T  X  F  F  F        =>        F  F  F  X  T  T  T
      T  T  T  F  F  F  F                  F  F  F  T  T  T  T
      T  T  T  F  F  F  F                  F  F  F  T  T  T  T
      T  T  T  F  F  F  F                  F  F  F  T  T  T  T

Toads can move horizontally right or vertically down and frogs can move horizontally left or vertically up. A move can be either a slide to the empty neighboring position or a jump over an opposing creature to the empty position right beyond it. Toads cannot jump over themselves and neither can Frogs.

How many jumps and slides are required for the toads to switch their positions with the frogs as depicted on the right above.

HINT: The puzzle is a two-dimensional version of the Problem 44709: Toads and Frogs Puzzle. It can be solved by applying the algorithm for that puzzle to the middle column. Whenever, a vacant cell is created in the board's row for the first time, switch to exchanging toads and frogs in that row by applying the same algorithm.

   T T F    T T F    T T F    T T F     T X F     X T F     F T X    F X T     F F T
   T X F    X T F    F T X    F X T     F T T     F T T     F T T    F T T     F T T
   T F F    T F F    T F F    T F F     T F F     T F F     T F F    T F F     T X F
           Slide 1  Jump 1   Slide 2   Slide 3   Slide 4   Jump 2   Slide 5   Jump 3
   F F T    F F T    F F T    F F T
   F T T    F T T    F T T    F X T
   X T F    F T X    F X T    F T T
  Slide 6  Jump 4   Slide 7  Slide 8

Therefore, to complete the puzzle for n = 1 requires four jumps and eight slides.

Goodluck!!!

Solution Stats

78.57% Correct | 21.43% Incorrect
Last Solution submitted on Mar 21, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers9

Suggested Problems

More from this Author18

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!