Blog     Github

Water Conservation


In the Berkeley Cleanweb 2.0 Hackathon, we took on the challenge of building a hack that brings attention to the worldwide water crisis. After hearing about the various datasets available to the public, we became particularly interested in the water costs of food, which actually accounts for 40% of the world’s water consumption. Data sources such as those available at can reveal how different foods from different places can cost drastically different amounts of water to produce. This led us to consider the question of what a water-conscious diet would look like. With any such diet, the objective of minimizing water consumption must be balanced by daily nutritional constraints. This immediately reminded us of the dual form to a famous combinatorial puzzle known as the Knapsack problem, in which a burglar aims to select museum artifacts so as to maximize the sum value of his loot bag, subject to a volume constraint on his bag! And this problem is typically solved using either dynamic programming or integer linear programming.

Our hack was thus to build an app that uses combinatorial optimization to generate water-friendly diets which satisfy user-specified nutritional constraints. Because these diets have the intention of saving the planet, we called it The Captain Planet Diet, in honor of a cartoon that Will used to watch as a kid. The hardest part was actually not the combinatorial optimization algorithm, but simply cross-referencing the USDA’s nutritional information with the data at, since different websites have different names for the same foods. Below you can see a sample execution of the app. We can see that Captain Planet would eat cabbages from Tanzania, Cucumbers from Brazil, Eggplants from the US, Onions from Brazil, etc.


The malicious user also has the option of selecting to be evil, in which case a diet is generated that maximizes water consumption. We call this the Galactus Diet, in honor of the Silver Surfer’s arch-enemy which devours planets wholesale throughout the universe. Below is a sample Galactus Diet. We see that Galactus eats lots of animals.


For more in-depth analyses, background information, and various data visualizations of foods and their water costs, please check out We hope you find it both humorous and educational.


Leave A Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.