Prepare the Cocktails
Description:
Laurence is on vacation at the tropics and wants to impress Juliet and her friends by making them the best cocktail he can from the island's bountiful fruits.
Taste and flavour
- Each ingredient has a unique integer taste representing its sweetness (if positive) or bitterness (if negative).
- The tastes of the ingredients sum up to the flavour of the cocktail.
- Cocktails will also have a non-negative integer bittersweetness. Each unit of bittersweetness is given by a unit of sweetness in contrast with a unit of bitterness (i.e. it's the lowest between the total sweetness and the total bitterness of the ingredients).
The same ingredient may be added multiple times to the same cocktail.
Well balanced drinks are made with exactly five ingredients. Use no more and no less for any cocktails you prepare. Repeated ingredients are counted as much as the quantity added.
Example cocktails
TASTE
Liquor -4
Vodka -2 FLAVOUR: 2
Mint 1 -----> BITTERSW: 6
Pineapple 3
Watermelon 4
Mormodica -6
Vodka -2 FLAVOUR: -2
Mint 1 -----> BITTERSW: 6
Orange 2
Pineapple 3
Input and output
Your solution will be called once per cocktail with the following parameters:
- The ingredients and their tastes as a dictionary of integers.
- The friend's desired flavour as an integer.
- The friend's desired bittersweetness as a non-negative integer.
Return an array of the ingredients used to make the cocktail. Order is irrelevant. Any answer respecting the criteria is valid. If it's impossible to make the cocktail you should return an empty array.
Test cases
Example test cases should be enough to confirm your output is correct. The real test cases will consist of the example test cases plus some randomized performance tests. These tests include datasets of size 26^2
and 26^4
. The maximum sweetness/bitterness of ingredients is 26^5
.
Similar Kata:
Stats:
Created | Feb 11, 2024 |
Published | Feb 16, 2024 |
Warriors Trained | 785 |
Total Skips | 14 |
Total Code Submissions | 957 |
Total Times Completed | 26 |
Python Completions | 17 |
JavaScript Completions | 11 |
Total Stars | 43 |
% of votes with a positive feedback rating | 92% of 12 |
Total "Very Satisfied" Votes | 10 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 4 kyu |