def knapsack(items, capacity, algorithm = :dynamic)
      if algorithm == :memoize
        knapsack_memoize(items, capacity)
      elsif algorithm == :dynamic
        knapsack_dynamic_programming(items, capacity)
      end
    end
def knapsack(items, capacity, algorithm = :dynamic)
      if algorithm == :memoize
        knapsack_memoize(items, capacity)
      elsif algorithm == :dynamic
        knapsack_dynamic_programming(items, capacity)
      end
    end
Given a set of items, each with a weight and a value, determines
 the maximum profit you can have while keeping the overall weight
 smaller than the capacity of the knapsack.

 @param items [Array<Array>] An array of pairs (weight, profit) representing the items
 @param capacity [Integer] The capacity of the knapsack
 @param algorithm [:memoize, :dynamic] The algorithm used to solve this, defaults to :dynamic