Water Jug Problem in AI — An Exploration with Python
A Simple Understanding of Water Jug Problem in AI | Karthikeyan Nagaraj
4 min readFeb 8, 2023
I just came across the topic of the water jug problem in my class and I wanted to share it with the Community of AI People Incorporated with a python program to Solve the Problem in a General Manner
Problem:
You are given with 2 Jugs, 4 Gallon and a 3 Gallon one. Neither of the jugs has any Measuring marks on it. There is a pump that can be used to fill the jugs with water. How can we get exactly 2 Gallons of water in 4 Gallon Jug?
Introduction:
- Water Jug Problem is a classic problem in Artificial Intelligence (AI) that involves finding a way to measure specific amounts of water using two jugs with different capacities.
- The goal is to reach a specific target amount of water in one of the jugs, without exceeding its capacity, by transferring water from one jug to another.
- This problem can be solved using a state space search algorithm.