Responding to The River Crossing Challenge!


What was the challenge ahead?

Recalling the conditions those need to be followed. 

--------------------------------------------------------------
  • They have a boat but only the men and the Gorilla can row the boat across, so there must always be a human and/or Gorilla on the boat.
  • The boat can only carry two people/monkeys.
  • If monkeys and humans are together on one side of the river there must be as many or more people than monkeys for the men's safety.
--------------------------------------------------------------
 
Here, we go step by step process. (M - Men, G - Gorilla, C - Chimps)

1. The gorilla takes 1 chimp across the river and comes back. 

    (M - 3, G - 1, C - 1 | M - 0, G - 0, C - 1) 

2. Again, gorilla takes 1 man across the river and comes back. 

    (M - 2, G - 1, C - 1 | M - 1, G - 0, C - 1)

Now, here gorilla can't take chimp across the river as that will violate condition 3 on that side. Neither gorilla can take 1 man on other side and return back since number of monkeys on returning side will be more than people again violating condition 3.

3. Next, one man drops gorilla at the other side and bring back chimp.

    (M - 2, G - 0, C - 2 | M - 1, G - 1, C - 0) 

4. Now, 2 men has to cross the river and send back gorilla for the rest of work.

   (M - 0, G - 1, C - 2 | M - 3, G - 0, C - 0) 

5. Finally, gorilla takes 2 chimps across the river in 2 round trips.

   (M - 0, G - 0, C - 0 | M - 3, G - 1, C - 2) 

Making it Across the River!
 

Comments

Follow me on Blogarama