You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: knapsack.rb
    path of file: ./repos/Ruby_on_Rails
    
    the code of the file until where you have to start completion: def stack_sack(items, weight, value, number)
  knapsack = Array.new(number + 1) { Array.new(items + 1, 0) }

    
def stack_sack(items, weight, value, number)
  knapsack = Array.new(number + 1) { Array.new(items + 1, 0) }

  # Build table for knapsack[][] in bottom-up manner
  for i in 0..number
    for j in 0..items
      if i == 0 || j == 0
        knapsack[i][j] = 0
      elsif weight[i - 1] <= j
        knapsack[i][j] = [value[i - 1] + knapsack[i - 1][j - weight[i - 1]], knapsack[i - 1][j]].max
      else
        knapsack[i][j] = knapsack[i - 1][j]
      end