You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const drinksByMostAlc = drinks.sort((a, b) => b.alcohol - a.alcohol); // most heave ones first
function* getDrinksByMostAlc(skip, targetAlc) {
let sum = 0;
for(const drink of drinksByMostAlc) {
if(skip(drink)) continue; // insert e.g. a randomizer here to pick different drinks each time
if(sum + drink.alcohol > targetAlc) continue; // gets the person more dizzy than wanted, skip
yield drink;
sum += drink.alcohol;
}
if(sum < targetAlc)
// not quite reached, do we get closer if we add the last one?
}
I think this is only about searching for which drinks are available given a set of ingredients, not searching for the best combination while optimizing the alcohol. While #27 is definetly worth implementing, it's not a necessary performance improvement since looping trough 150-ish drinks is okay. However, looping trough 150 * 150 * 150 combinations as in the current implementation of the alcohol optimization IS a performance problem.
The current implementation is brute-forcing every combination of drinks for up to 3 drinks.
The text was updated successfully, but these errors were encountered: