00:01
Hello students, so here is the implementation of a motor jug problem using depth -first search dfs in python.
00:07
So here i have taken the function motor underscore jug underscore problem.
00:11
So here jug underscore cap jug1 underscore cap jug2 underscore cap and targets.
00:21
So here function jug if state is valid.
00:24
So two jug capacities are taken and these are these are represented with the variable of jug1 underscore cap and jug2 underscore cap.
00:33
Now so is underscore valid underscore state now it is a function to check if the state is valid.
00:40
So here jug1 jug2 is equal to state return zero less than or equal to jug1 less than or equal to jug1 underscore capacity and zero less than or equal to jug2 less than or equal to jug2 underscore capacity function to generate the possible states from the given state.
01:00
So here i have taken the function generate underscore next underscore state here i am passing argument state.
01:07
So here jug1 jug2 is state and next state is here empty.
01:11
Now find the jug1 completely.
01:14
So if jug1 is less than jug1 underscore capacity means jug1 underscore capacity is greater than next underscore state dot append jug1 underscore capacity jug2.
01:27
So here after two jug1 is completely fill jug1 completely now fill now our next task is to fill the jug2 completely.
01:37
So if jug2 is less than the capacity then next work is next underscore state dot append jug1 jug2 underscore capacity.
01:47
Now empty the jug1 so if jug1 is greater than zero so we can we can send it to the next underscore state dot append zero comma jug2.
02:01
So now it can be appended.
02:03
Now empty the jug2 if jug2 is greater than zero now next underscore state dot append jug1 dot comma zero.
02:11
Pour the water from jug1 to jug2 now if jug1 is greater than zero and jug2 is less than jug2 underscore capacity then amount underscore to underscore pour i have to take the minimum one.
02:27
So jug1 jug2 underscore capacity minus jug2 now next underscore state dot append jug1 minus amount underscore to underscore pour comma jug2 amount underscore to underscore pour.
02:42
So in this way we can append now pour the water from jug2 to jug1.
02:47
So now our task is to pour the water from jug2 to jug1.
02:52
So here this is jug2 and this is jug1...