Optimal Bags for Specific Apple Count

Identify the optimal number of bags needed to buy a specific quantity of apples, sold in batches of 6 or 8.

You need to buy apples from a grocery store, which only sells apples in pre-packed bags of 6 or 8. The bags cannot be opened to take out individual apples. Your challenge: given a specific number `n` of apples, determine the minimum number of bags needed to buy exactly `n` apples. If it's not possible to buy exactly `n` apples with these bag sizes, return a signal value. Your task is to write the function `min_bags(apple_count)` that returns the minimum number of bags needed to buy exactly `n` apples, where it's possible; if not, it should return -1. ### Parameters - `apple_count` (integer): The precise number of apples to be bought. ### Return Value - Returns an integer specifying the minimum number of bags needed to buy exactly `n` apples; returns -1 if such an exact purchase isn't possible. ### Examples ```python # To buy exactly 20 apples, you can buy 2 bags of 8 apples (16) and 1 bag of 6 apples (4) min_bags(20) ➞ 3 # 15 apples cannot be bought with the given bag sizes min_bags(15) ➞ -1 # For 28 apples; 4 bags of 8 apples each min_bags(28) ➞ 4 ```