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 challengesWater Jugs

Gamified challenge · BFS over states

Water Jugs

You have a tap and two unmarked jugs: jug A holds a litres and jug B holds b litres, and both start empty. Each step is one operation: "fill A", "fill B", "empty A", "empty B", "pour A B" or "pour B A" (a pour stops when the source is empty or the destination is full).

Write measure(a, b, target) that returns the fewest operations after which either jug holds exactly target litres, or an empty list if that's impossible. For a = 3, b = 5, target = 4 that takes 6 steps, e.g. ["fill B", "pour B A", "empty A", "pour B A", "fill B", "pour B A"].

Sign in to play Water Jugs

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