other.greedy ============ .. py:module:: other.greedy Classes ------- .. autoapisummary:: other.greedy.Things Functions --------- .. autoapisummary:: other.greedy.build_menu other.greedy.greedy other.greedy.test_greedy Module Contents --------------- .. py:class:: Things(name, value, weight) .. py:method:: __repr__() .. py:method:: get_name() .. py:method:: get_value() .. py:method:: get_weight() .. py:method:: value_weight() .. py:attribute:: name .. py:attribute:: value .. py:attribute:: weight .. py:function:: build_menu(name, value, weight) .. py:function:: greedy(item, max_cost, key_func) .. py:function:: test_greedy() >>> food = ["Burger", "Pizza", "Coca Cola", "Rice", ... "Sambhar", "Chicken", "Fries", "Milk"] >>> value = [80, 100, 60, 70, 50, 110, 90, 60] >>> weight = [40, 60, 40, 70, 100, 85, 55, 70] >>> foods = build_menu(food, value, weight) >>> foods # doctest: +NORMALIZE_WHITESPACE [Things(Burger, 80, 40), Things(Pizza, 100, 60), Things(Coca Cola, 60, 40), Things(Rice, 70, 70), Things(Sambhar, 50, 100), Things(Chicken, 110, 85), Things(Fries, 90, 55), Things(Milk, 60, 70)] >>> greedy(foods, 500, Things.get_value) # doctest: +NORMALIZE_WHITESPACE ([Things(Chicken, 110, 85), Things(Pizza, 100, 60), Things(Fries, 90, 55), Things(Burger, 80, 40), Things(Rice, 70, 70), Things(Coca Cola, 60, 40), Things(Milk, 60, 70)], 570.0)