Advertisement
Guest User

Untitled

a guest
Oct 18th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. “The three witches in Hamlet can brew any potion provided they have the right ingredients. Suppose that five ingredients are necessary in making a health potion: eye of newt (eon), toe of frog (tof), wool of bat (wob), adder’s fork (af), and tooth of wolf (tow). Four reactions can occur between these ingredients:
  2. 4 eon + 2 wob = 3 af + 4 tow
  3. 3 tow + 1 tof = 2 eon
  4. 1 wob + 2 af = 1 tof
  5. 4 tof + 7 tow + 2 af = 1 health potion
  6. Assuming you can control the order of reactions, write a program that can calculate the maximum number of health potions one can brew with a given amount of ingredients. Here is example output:
  7. If I have 34 eon, 59 tof, 20 wob, 5 af, and 20 tow, I can make seven health potions.”
  8.  
  9. Excerpt From: Ophir Frieder, Gideon Frieder, and David Grossman. “Computer Science Programming Basics with Ruby.” iBooks.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement