Find out how many laptops Molly can buy based on available money, array of quantities and array of costs
My understanding of the problem:

You are provided three values:


A budget(the amount of funds you can spend)
A List of Vendor Batch Sizes
A List of Vendor Batch Prices


Promises/Assumptions: the items 2 &amp; 3(the lists) correspond such that for Vendor i, the vendors batch size and price can be found at List.get(i)

NOTE: Your code has a hard-coded assumption that the two lists (budgetQuantities and budgetCosts) are the same size, or at least you never check that this is true or otherwise enforce this requirement.

Goal: determine the maximum affordable quantity based on Vendor and budget information.



There seems to be some superfluous code going on here, so I will try to address that first

Inner Class MaxQuantity

There really isn't any reason to use this. It has only one use: to interact with the internal int value. As both the class and value are public, I can access all the way through: shoppingBudget.MaxQuantity.value. This is generally considered bad. As the class is in all cases just an int, it can be replaced with an internal variable, private int maxQuantity

suggesting removal


The permute function

As mentioned in my comment, this function seems entirely pointless as the problem does not involve permutations; The information is linear in nature, as there is no "mix and match" (i.e. permutation) of Vendor Information (budgetQuantities and budgetCosts) 

suggesting removal

Update
I appreciate your use of recursion in your permute function, but its a tad confusing. The second set of swapping seems pointless, as by the time you reach it you are simply propagating back up the recursion tree, swapping indeces that we no longer use.

I looked for similar permutation implementations and found this well designed permutation util, which I used for comparison testing of your permutation method. 


IntStream
There really isn't a need to create an int[] for indices like this. I see it is mostly used in the permute() function, which I have suggested removing, so I will likewise suggest removing this. With a linear solution, it is much easier to create a single int index and increment it as we iterate through the lists, rather than creating an int for every position from 0 to budgetQuantities,size()-1 (the increment approach is also less computationally expensive, especially where memory is concerned)

Update I had to use this in my rework, definitely shouldn't remove


maxQuantity.value = Integer.MIN_VALUE;

Integer.MIN_VALUE is usually a good initial value for a maximum. However, this is not the true minimum of the problem. The absolute minimum items you can purchase is 0, so it makes more sense to initialize your globalMaximum to 0: private int globalMaximum=0;

UPDATED

findSolution is NOT broken

There is a hole in the logic of your findSolution method. You seem to have written your code with the intent that this method will be called many times, and each result will be compared with the global max (based on your use of maxQuantity.value = Math.max(maxQuantity.value, possibleMax); in permute)

However, this method runs across all vendors. Because of this, your int remaining and counter should be inside your for loop, with an int localMaximumToReturn where counter is currently.

To explain further: your current findSolution forEach loop represents each Possible Interaction between Molly and one Vendor, so both the money available and the total number of computers she can buy per transaction are independent. However, in the above code, each loop is interacting with the same funds, which will introduce severe error.

Example: I ran in debug with breakpoints inside the findSolution method, outside the forEach loop, with the following information:

moneyAvailable: 50
budgetQuantities: {20,19}
budgetCosts: {24,20}


Stepping through, the first loop correctly computes that howManyToBut is 2, meaning she can buy 40 computers for 48 dollars. Then you set remaining to 2 with remaining -= 48

This means for the next loop, we get a cost of 20, which is now greater than our remaining 2 so the second cost/quantity maximum is never checked

We have technically hit each index, so we leave the loop and return the counter 40. While this IS the correct answer, we got here by false means. If you switch the order of items in your lists for the first assert, you should see a return of 38, which will break your assertEqual

It is at this point I see the point of permute in that it was scrambling your orders. Since your findSolution would only ever succeed at checking the first index, permute scrambles your orders so that each item gets a shot at being first, so each possible results is compared with the globalMax. While this works, it is incredibly backward, and buggy I highly recommend fixing this bug in findSolution, and remove the no longer needed permute()



With superfluous code removed you should end up with something similar to:

public class ShoppingBudget {
    int globalMax;

    public int budgetShopping(int budget, List&lt;Integer&gt; batchSizes, List&lt;Integer&gt; batchCosts) {
        List&lt;Integer&gt; indeces = new ArrayList&lt;&gt;();
        IntStream.range(0, batchSizes.size()).forEach((num) -&gt; indeces.add(num));
        Collection&lt;List&lt;Integer&gt;&gt; permutations = new Permutations&lt;Integer&gt;().permute(indeces);
        permutations.forEach(
                (permutation) -&gt; checkPermutationMaximum(permutation, budget, batchSizes, batchCosts)
        );
        return globalMax;
    }

    private void checkPermutationMaximum(List&lt;Integer&gt; indeces, int budget, List&lt;Integer&gt; batchSizes, List&lt;Integer&gt; batchCosts) {
        int localMax = 0;
        int remainingCash = budget;

        int i = 0;
        int sz = indeces.size();
        while (i &lt; sz &amp;&amp; remainingCash &gt; 0) {
            int currentVendor = indeces.get(i);
            int currentCost = batchCosts.get(currentVendor);
            if (remainingCash &gt;= currentCost) {
                int cashToCostRatio = remainingCash / currentCost;
                remainingCash -= currentCost * cashToCostRatio;
                localMax += cashToCostRatio * batchSizes.get(currentVendor);
            }
            i++;
        }

        if (localMax &gt; globalMax) globalMax = localMax;

    }
}


The above passes all of your assertEqual tests as well as debug scrutiny


Comments on Update

Rather than trying to create the next unvisited permutation at run time (which is your above approach) I adapted a utility to return a Collection of Lists, where each List is a possible permutation of the input. Then I compute and check the maximum for each permutation