private Inventory solveSmartlyRecursively(int indexOfNextItem, int remainingCapacity, ArrayList<Double> result, int value) {
        if (indexOfNextItem >= items.size()) {
            return new Inventory(this, result, value);
        }
        
        Item nextItem = items.get(indexOfNextItem);

        result.add(0.0);
        Inventory resultWhenExcluded = solveSmartlyRecursively(indexOfNextItem + 1, remainingCapacity, result, value);

        if (nextItem.getWeight() > remainingCapacity) {
            result.remove(result.size() - 1);
            return resultWhenExcluded;
        } else {
            result.set(result.size() - 1, 1.0);
            Inventory resultWhenIncluded = solveSmartlyRecursively(indexOfNextItem + 1, remainingCapacity - nextItem.getWeight(), result, value + nextItem.getValue());
            result.remove(result.size() - 1);
            if (resultWhenIncluded.getTotalValue() >= resultWhenExcluded.getTotalValue()) {
                return resultWhenIncluded;
            } else {
                return resultWhenExcluded;
            }
        }
    }