Warning: Parameter 1 to wp_default_scripts() expected to be a reference, value given in /home/public/wp-includes/plugin.php on line 571

Warning: Parameter 1 to wp_default_styles() expected to be a reference, value given in /home/public/wp-includes/plugin.php on line 571

Warning: Parameter 1 to wp_default_scripts() expected to be a reference, value given in /home/public/wp-includes/plugin.php on line 571
logic | Ash Tewari

Solve puzzle with code

Here is a quite common programming interview puzzle – You have two buckets. A 3 gallon bucket and a 5 gallon bucket. Buckets are not marked or graduated. You are to fetch 4 gallon of water in a single trip to the river. How will you do it? Obviousy, this question is asked by changing the capacities of the two buckets and the amount of water to be fetched. Your mission, should you choose to accept it, is to write a program to solve this puzzle in a generic way. Your program should take 3 inputs – capacities of the two buckets and the amount of water to be fetched. After solving the puzzle, your program must write out the […]