irrelevant too. From p and c, we cannot reconstruct the sizes of the individual pieces. But, that is irrelevant to solving the problem. Example .
. Consider Example . , Goat, grass and wolf problem. In this example, we will write a specification of the problem.
We will solve it in Example . . The problem involves four individuals, and each is at one of the two sides of the river. This means that we can represent the state by four variables, and each of them has one of the two values.
Let us name the variables as farmer, goat, grass and wolf, and their possible values L and R. A value of L means "at the left side". A value of R means "at the right side". Since the boat is always with the farmer, it is not important to introduce a variable to represent its position.
In the initial state, all four variables farmer, goat, grass, wolf have the value L. farmer, goat, grass, wolf = L, L, L, L In the final state, all four variables should have the value R. farmer, goat, grass, wolf = R, R, R, R The specification of the problem is -- inputs: farmer, goat, grass, wolf = L, L, L, L -- outputs: farmer, goat, grass, wolf = R, R, R, R subject to the two constraints that . the goat cannot be left alone with the grass: if goat = grass then farmer = goat .
the goat cannot be left alone with the wolf: if goat = wolf then farmer = goat . . Assignment statement Variables are named boxes to store values. Assignment statement is used to store a value in a variable.
It is written with the variable on the left side of the assignment operator and a value on the right side. variable := value When this assignment is executed, the value on the right side is stored in the variable on the left side. The assignment m := stores value in variable m. m If the variable already has a value stored in it, assignment