20/04/2012 The Jugs – Level 1 You have a 7, 4 and 2 liter water container. Each container has no markings except for that which gives you it's total volume. You also have a running tap. You must use the containers and the tap in such a way as to exactly measure out 1 liters of water. How is this done? Use only the water containers given. Overflows are not allowed. You can poor away the content of a can in the sink but in general try to pour away as less water as possible. What actions are available? Pick the small jug Pour the jug in hand in the small jug Turn the faucet on Pick the medium jug Pour the jug in hand in the medium jug Fill the jug at the faucet Pick the big jug Pour the jug in hand in the big jug Turn the faucet off Empty the jug in the sink Release the jug in hand What tests are available? The big jug is full The big jug is empty The medium jug is full The medium jug is empty The small jug is full The small jug is small The faucet is on The faucet is off The jugs – Level 1 Page 2 Implementation of small scale scenarios How can we instruct the robot to turn on and off the faucet? Can you instruct the robot to fill in all the jugs in the faucet (do not forget to turn off the faucet and to place all the jugs back on the table)? Can you instruct the robot to fill in the big jug at the faucet and to pure the content in the medium jug. Answer ► Answer ► How can we instruct the robot to pick up the big up the big jug and to fill it at the faucet? Answer ► Answer ► Can you explain what does these labels mean? Change the script above, so as less water to be spoiled. Coupled with this, release the jug in hand. This label means that the jug contains now 3 liters of water but it can hold up to 7. Answer ► Faucet is off ► This label means that the jug contains now 4 liters of water and it can hold up to 4. Thereby, this jug is full. Note: No label exists for jugs that are totally empty. Jug is released ► The optimal solution for Level 1. The script is based on the following 3 actions: 1. Fill the 7-liter container ( 7 , 0 , 0). 2. Pour the 7-liter container into the 2-liter container ( 5 , 0, 2 ). 3. Pour the 7-liter container into the 4-liter container ( 1 , 4, 2 ). Extra commands, such as ‘turn the faucet off’ and ‘release the jug in hand’ can be added to this script. The Jugs– Level 1 Page 3 Less optimal solutions Main idea underpinning solution 1: Main idea underpinning solution 1: 1. Fill the 7-liter container at the faucet (7 , 0 , 0). 2. Pour the 7-liter container into the 4-liter container (3 , 4, 0). 3. Pour the 4-liter container into the 2-liter container (3 , 2, 2 ). 4. Pour the 7-liter container into the 4-liter container (1 , 4, 2). 1.Fill the 7-liter container at the faucet (7 , 0 , 0). 2. Pour the 7-liter container into the 2-liter container (5 , 0, 2). 3. Pour the 7-liter container into the 4-liter container (3 , 2, 2 ). 4. Pour the 7-liter container into the 4-liter container (1 , 4, 2). The commands ‘turn off the faucet’ and ‘release the jug in hand’ can be added. The commands ‘turn off the faucet’ and ‘release the jug in hand’ can be added. Playing with jugs and programming constructs! Imagine that this is the current state ► and we address this script ► Can you tell what does the script do? As long as the big jug is empty, the faucet is turn on and off. Can you tell how many times the script will be executed? The script runs forever, because the big jug is always found to be empty. How many times the faucet will be turn on? Infinitive. How many times the faucet will be turn off? Infinitive. Can you draw a state on which the ‘While– loop’ is never executed? Answer ► This project has been funded with support from the European Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
© Copyright 2026 Paperzz