Participant Count from Coffee and Milk Shares
Updated
Problem statement
Coffee and milk are shared among an unknown positive integer number of participants. Every participant receives the same combined volume servingOunces, with different coffee-to-milk ratios. One participant receives exactly 1/coffeeDenominator of the entire coffee supply and 1/milkDenominator of the entire milk supply.
For this exercise, assume both total supplies are strictly positive, both supplies are fully distributed, and amounts may be divided into fractions of an ounce. Everyone receives the same total volume, but their coffee-to-milk ratios do not have to match.
For this exercise, assume the denominators are integers differing by exactly 2. This generalizes the denominators 4 and 6 of the first example while keeping a uniquely determined integer participant count. In the first example each serving is 8 ounces; in general the positive serving volume is an input.
Complete participantCount(coffeeDenominator, milkDenominator, servingOunces) and return the unique total number of participants. The answer is a count, rather than the combined supply volume.
Function
participantCount(coffeeDenominator: int, milkDenominator: int, servingOunces: int) → intExamples
Example 1
coffeeDenominator = 4milkDenominator = 6servingOunces = 8return = 5This is the case the statement refers to. A total of 16 ounces of coffee and 24 ounces of milk gives five equal eight-ounce servings. The specified participant receives 16/4 + 24/6 = 8 ounces. One possible distribution of coffee/milk ounces is (4,4), (0.5,7.5), (1.5,6.5), (4.5,3.5) and (5.5,2.5); all five ratios are different.
Example 2
coffeeDenominator = 2milkDenominator = 4servingOunces = 3return = 3This example admits 3 ounces of coffee and 6 ounces of milk. The specified participant receives 3/2 + 6/4 = 3 ounces. The combined nine ounces make three equal servings.
Example 3
coffeeDenominator = 8milkDenominator = 6servingOunces = 1return = 7This example reverses the smaller denominator. Coffee and milk totals can be 4 and 3 ounces. The specified participant receives 4/8 + 3/6 = 1 ounce, and there are seven equal servings.
Constraints
- For this exercise, assume
2 <= coffeeDenominator, milkDenominator <= 10^5. abs(coffeeDenominator - milkDenominator) = 2.- For this exercise, assume
1 <= servingOunces <= 10^6. - Both entire supplies are positive and completely distributed in equal combined servings.
- Fluid volumes need not be whole numbers of ounces.
More IMC Trading Phone Screen questions
- Election District Budget Allocation AnalysisPHONE SCREEN · Seen Aug 2026
- Uniform Variables: Smaller Below Larger SquaredPHONE SCREEN · Seen Mar 2026
- Combination Sum with Unlimited ReusePHONE SCREEN · Seen Dec 2025
- Valid Range of a Three-Outcome Probability ParameterPHONE SCREEN · Seen Dec 2025
- Expected Fishing CatchPHONE SCREEN · Seen Dec 2025
- Count Routes Through a City GridPHONE SCREEN · Seen Nov 2024
- Expected City Arrival and Return DaysPHONE SCREEN · Seen Nov 2024
- Stationary City Population SharesPHONE SCREEN · Seen Nov 2024
- Maximum Falling Path SumPHONE SCREEN · Seen Nov 2024
- Trading Profit Percentage ChangePHONE SCREEN · Seen Feb 2024
Similar questions at other companies
- Parking Fee CalculatorBreeze · PHONE SCREEN
- Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
- Sqrt(x)LinkedIn · PHONE SCREENLinkedIn interview questions
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Circular Primes Below a LimitAmazon · PHONE SCREEN
- Palindrome NumberKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
- Streaming AverageXantium · PHONE SCREEN
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN