A Froggy Game of Logic

Logic Level 4

There are 5 green frogs on the left side of the swamp and 5 blue frogs on the right side of the swamp. They are sitting on rocks. The central rock is empty.

Your task is to swap their places. i.e.: at the end the 5 blue frogs should be on the left, the 5 green frogs should be on the right and the central rock should be free.

Each frog can only move forward. The direction of travel is shown by the respective arrows.

A frog can advance by one step, if the space in front of it is free.

A frog can jump over another, only if the other frog is of the other color. You can jump over only one frog of other color at a time into the vacant space immediately behind it.

How many moves would it take for the green and blue frogs to swap places?

Can you generalize for n n frogs on either side?

This problem is inspired by a game I watched my kids play.


The answer is 35.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Satyen Nabar
Jun 10, 2015

The key idea here is, that you never want to be in a position where two frogs of the same color are next to each other.

As the frogs have to alternate with each other and jump over each other, that makes n n = n 2 n*n=n^2 jumps. The n + n = 2 n n+n= 2n are the non-jump slides that the frogs move.

The generalization is that for n n frogs on either side it will take n 2 + 2 n n^2+2n or ( n + 1 ) 2 1 (n+1)^2 -1 moves.

Moderator note:

Your final answer is right. Can you elaborate on it?

I had a computer game named 'Frog Puzzle ' which was same as this problem

Log in to reply

There is Android game - river iq This puzzle was there too..

Divyansh Chaturvedi - 5 years, 12 months ago
Joe Mansley
Aug 1, 2020

The average number of spaces a frog advances is n+1. There are 2n frogs. So the total number of spaces advanced is 2n(n+1). The frogs advance one space for every step, so they would need 2n(n+1) moves, but every jump the frog advances 2 spaces, so we save ourselves a move. The number of jumps is n*n=n^2 (since there is one jump for each green-blue frog pair). So assuming that it's possible to switch the frogs, the number of moves must be 2n(n+1)-n^2=n^2+2n.

Now we just need to show that it is possible to switch the frogs. I've tried to show this below in the n=5 case (not showing every move). We can use the same approach for other values of n.

GGGGG_BBBBB

GGGG_GBBBBB

GGGGBG_BBBB

GGGGBG_BBBB

GGGGBGB_BBB

GGG_BGBGBBB

GG_GBGBGBBB

GGBGBGBG_BB

GGBGBGBGB_B

G_BGBGBGBGB

_GBGBGBGBGB

BGBGBGBGBG_

BGBGBGBGB_G

B_BGBGBGBGG

BB_GBGBGBGG

BBBGBGBG_GG

Etcetera.

Thorvald Dox
Jan 10, 2019

For each frog, one can consider two variables. The first variable, let's call this a a , is the distance a frog has to move to end up at it's final position. The second one, b b , is the number of frogs it has to jump over. Now, let T T be the sum of a b / 2 a-b/2 over all frogs. If a frog moves a single unit forward, a will decrease and b remain constant, so T will decrease by one. If a frog jumps over another frog, a will decrease by two, but b will decrease by one for both the moving frog, and the frog it jumped over, resulting also in T decreasing by one. By consequence, T decreases by one every step. As a starts at (n+1) for every frog and b at n, T starts at 2 n ( n + 1 ) n 2 = n ( n + 2 ) 2n(n+1) - n^2= n(n+2) . As it ends at 0, it can only finish in n ( n + 2 ) n(n+2) moves, or 35 if n=5

Vraj Mistry
Jun 12, 2015

Let n be the no. of Frogs on each side.

formula that applies to is n(n+2)

therefore,5(5+2)=3*7=35

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...