code: def knapsack_iterative_numpy(items, maxweight):
      items = np.array(items)
      weights = items.T[1]
      max_exp = max([number_of_decimals(w_) for w_ in weights])
      coeff = 10 ** max_exp
      weights = (weights * coeff).astype(np.int)
      values  = items.T[0]
      MAXWEIGHT = int(maxweight * coeff)
      W_SIZE = MAXWEIGHT + 1
      dpmat = np.full((len(items), W_SIZE), np.inf)
      kmat = np.full((len(items), W_SIZE), 0, dtype=np.bool)
      idx_subset = []
      for w in range(W_SIZE):
          dpmat[0][w] = 0
      for idx in range(1, len(items)):
          item_val = values[idx]
          item_weight = weights[idx]
          for w in range(W_SIZE):
              valid_item = item_weight <= w
              prev_val = dpmat[idx - 1][w]
              if valid_item:
                  prev_noitem_val = dpmat[idx - 1][w - item_weight]
                  withitem_val = item_val + prev_noitem_val
                  more_valuable = withitem_val > prev_val
              else:
                  more_valuable = False
              dpmat[idx][w] = withitem_val if more_valuable else prev_val
              kmat[idx][w] = more_valuable
      K = MAXWEIGHT
      for idx in reversed(range(1, len(items))):
          if kmat[idx, K]:
              idx_subset.append(idx)
              K = K - weights[idx]
      idx_subset = sorted(idx_subset)
      items_subset = [items[i] for i in idx_subset]
      total_value = dpmat[len(items) - 1][MAXWEIGHT]
      return total_value, items_subset