Very strange. In the advantaged case, by hand I get (5, 42, 11)->3 (like you do), but I get (20, 2.5, 3)->25, not the 27 you do. The program gets (5, 42, 11)->9, (20, 2.5, 3)->33. Which seems off, but look at that code (the second one I sent): it's so simple, where would the error be?
Lunch break's over, and I'm playing IRL tonight, so I won't have a chance to look at it again until tomorrow =\