todomvp

所属分类:OA办公系统
开发工具:JavaScript
文件大小:0KB
下载次数:0
上传日期:2015-06-17 01:02:59
上 传 者sh-1993
说明:  最低生活必胜客
(Minimum Viable Pizza)

文件列表:
Procfile (31, 2015-06-16)
dist/ (0, 2015-06-16)
dist/script.js (1043157, 2015-06-16)
dist/script.js.map (1211311, 2015-06-16)
index.html (194, 2015-06-16)
package.json (863, 2015-06-16)
public/ (0, 2015-06-16)
public/doge.css (621, 2015-06-16)
public/img/ (0, 2015-06-16)
public/img/burst.png (3280, 2015-06-16)
public/img/pizza.png (1173219, 2015-06-16)
public/img/pizzadoge.jpg (21395, 2015-06-16)
public/img/star.png (2880, 2015-06-16)
public/style.css (1633, 2015-06-16)
script.js (864510, 2015-06-16)
script.js.map (1015319, 2015-06-16)
src/ (0, 2015-06-16)
src/app.js (786, 2015-06-16)
src/initial.js (1169, 2015-06-16)
src/intent.js (1856, 2015-06-16)
src/model.js (3870, 2015-06-16)
src/propHook.js (247, 2015-06-16)
src/server/ (0, 2015-06-16)
src/server/conf.js (89, 2015-06-16)
src/server/db.js (347, 2015-06-16)
src/server/server.js (3210, 2015-06-16)
src/server/views/ (0, 2015-06-16)
src/server/views/index.jade (461, 2015-06-16)
src/view.js (4213, 2015-06-16)
src/wsDriver.js (772, 2015-06-16)
src/wsEffects.js (755, 2015-06-16)
src/wsIntent.js (339, 2015-06-16)
webpack.js.conf (284, 2015-06-16)

# TODO: Minimum Viable Pizza Let's face it: todo lists are overdone. We know what we need to do - we need to order pizza. But how much? The TODO: MVP algorithm accepts the following inputs: * A standard "slice" size * Total number of slices that the group desires * The pizza sizes and prices of the pizza shop The TODO: MVP algorithm will in turn recommend several pizza ordering options that will satisfy the group's cravings. ## What can I do with it? Well, you could use it to figure out what pizza to order. You could also use it instead of TodoMVC to try out a new library/framework/etc. ## How does the MVP algorithm work? It just generates permutations of all of the pizza configurations that order enough pizza, without ordering an extra pizza, and then ranks and sorts them on several axes. ## Reference Implementation ```javascript var _ = require('lodash'); function mvp(numServings, servingSize, pizzas, sortBy) { var totalSize = numServings * servingSize; pizzas = _.sortBy(pizzas, 'diameter').reverse(); function updateTotal(option) { option.total = _(option.pizzas) .map('diameter') .map(d => d / 2) .map(r => r * r) .map(r2 => r2 * Math.PI) .reduce((sum, area) => area + sum); } function addPizza(option, options, index) { index = index || 0; if (option.total > totalSize) { options.push(option); } else { for (let i = index; i < pizzas.length; ++i) { var newOp = {pizzas: _.clone(option.pizzas)}; newOp.pizzas.push(pizzas[i]); updateTotal(newOp); addPizza(newOp, options, i); } } return options; } return _(addPizza({pizzas: [], total: 0}, [])) .flatten() .tap(options => console.log(`Found ${options.length} options`)) .forEach(option => { option.cost = _(option.pizzas) .map('cost') .reduce((sum, cost) => sum + cost); option.ratio = option.cost / option.total; }) .sortBy('ratio') .forEach((option, index) => option.order = index + 1) .sortBy('total') .forEach((option, index) => option.order += index) .sortBy(sortBy) .take(10) .sortBy('total') .tap(options => options[options.length - 1].special = 'Most pizza! ') .sortBy('ratio') .tap(options => options[0].special = (options[0].special ? options[0].special : '') + 'Best deal!') .sortBy(sortBy) .value(); } var topTenPizzas = mvp(20 /*slices of pizza*/, 20 /*square inches per slice*/, [ {name: 'Large', diameter: 16, cost: 12.95}, {name: 'Medium', diameter: 14, cost: 9.95}, {name: 'Small', diameter: 12, cost: 8.95} ] /* Monte Cellos' pizza menu */, 'order' /* sort by PizzaRank */); ```

近期下载者

相关文件


收藏者