Try This Computer Science Problem

Gabriel wants to fill up a large empty vase which can contain 10 liters of water. His robot is programmed to repeatedly fill a 1 liter water bottle, and empty the entire contents into the vase. Gabriel decides to program the robot to stop when the vase contains exactly 8 liters of water. What will happen?

The vase will be filled with exactly 10 liters of water The vase will overflow The vase will be filled with exactly 8 liters of water The vase will be filled with exactly 1 liters of water

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Calvin Lin Staff
Jul 2, 2014

The robot will repeatedly fill the vase till there are 8 liters of water. At which point, the program will terminate.

Problem could be made more interesting by adding something like this: Robot fills the bottle and then checks the amount of water in the vase. What will happen? Answer: Vase will contain exactly 8 litres of water and bottle will be filled. Other choices could be: Vase will contain 9 litres of water and bottle will be empty, Vase will contain 7 litres of water and water will be filled etc

Snehal Shekatkar - 6 years, 11 months ago

it seems make me confused sometimes..................

Dony Chrisdianto - 6 years, 10 months ago

The question said that the entire contents are emptied in the vase. Doesn't that mean that the bottle is also thrown in it?

Debmeet Banerjee - 5 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...