寻找将“食物价值”和“含酒精和糖醇的食物”的 Weight Watcher PointsPlus 公式编码为 Ruby 和/或 PHP 的正确方法。
这是公式的链接:http ://en.wikipedia.org/wiki/Weight_Watchers#Formulas
在此先感谢您的帮助!
更新:
根据下面@mjayt 的帮助,我有下面的代码。我的目标是学习如何通过代码正确思考、组织和解决公式。我相信帮助正确解决这两个公式将有很大帮助。再次感谢。
$protein = 8;
$carbs = 30;
$fat = 12;
$fiber = 8;
$pointsplus = round((($protein * 16) + ($carbs * 19) + ($fat * 45) - ($fiber * 14)) / 175, 0);
echo $pointsplus;