GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesRiver Crossing Trio

Gamified challenge · Breadth-first search

River Crossing Trio

A farmer and the items start on the left bank of a river. The boat must carry the farmer, plus at most one item, on every crossing; crossings alternate left → right, right → left, and so on. Each string in conflicts names two items, like "wolf goat", that must never be left on the same bank without the farmer (checked after every crossing).

Write crossing(items, conflicts) that returns the crossings in order: each is the name of the item the farmer takes, or "alone" when the boat carries only the farmer. Everyone, farmer included, must end on the right bank, using the fewest crossings possible; any shortest safe plan passes. If no safe plan exists, return an empty list.

Example: items = ["fox", "hen"], conflicts = ["fox hen"] → ["fox", "alone", "hen"] (or ["hen", "alone", "fox"]).

Sign in to play River Crossing Trio

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account