FastPrepMacaron Order Price
Problems/Macaron Order Price

Macaron Order Price

OpenAI logoOpenAI● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an OpenAI online assessment for a full-time role. The report gives the rules for filling a set and for discounts. It leaves out the number limits and the money precision. Here prices are whole units, and totals are exact to a hundredth of a unit.

Our version is about 95% the same as the reported question.

A baker sells macarons with at most five distinct flavors. Every macaron has the same unit price. You are given quantities, where quantities[i] is the number of macarons of the i-th distinct flavor in an order, and an integer unitPrice in whole currency units.

The baker packs the order into sets. Each set contains at most five macarons and at most one macaron of any flavor. To fill each set as much as possible, the baker repeatedly takes one macaron from every flavor that still has a positive quantity, then starts the next set. The order of flavors within a set and the order of the completed sets do not matter.

Each set receives a discount based on its number of distinct flavors:

  • One flavor: no discount.
  • Two flavors: 10% off the price of the set.
  • Three flavors: 20% off the price of the set.
  • Four flavors: 30% off the price of the set.
  • Five flavors: 40% off the price of the set.

The undiscounted price of a set is its number of macarons multiplied by unitPrice. Return the total discounted order price as an integer number of hundredths of a currency unit. For example, a price of 14 currency units is returned as 1400. No rounding is needed.

Function

macaronOrderPrice(quantities: int[], unitPrice: int) → long

Examples

Example 1

quantities = [2,2,1,1,1]unitPrice = 10return = 4800

The first set has five flavors and costs 5 × 10 × 0.6 = 30 currency units. The second has two flavors and costs 2 × 10 × 0.9 = 18. The total is 48 units, so return 4800.

Example 2

quantities = [3,0,0]unitPrice = 2return = 600

Only one flavor is present, so the baker makes three single-macaron sets. There is no discount: 3 × 2 = 6 currency units, or 600 hundredths.

Example 3

quantities = [3,1,2,0,2]unitPrice = 4return = 2480

The set sizes are 4, 3, and 1. Their prices are 11.2, 9.6, and 4 currency units. The total is 24.8 units, so return 2480.

Constraints

  • 1 <= quantities.length <= 5.
  • 0 <= quantities[i] <= 10^6.
  • At least one entry in quantities is positive.
  • 1 <= unitPrice <= 10^4.
  • The returned price fits in a signed 64-bit integer.

More OpenAI Online Assessment questions

  • Count Routes Through Four Shop TypesOA · Seen Oct 2026
  • Digit-Sum Sequence Join PointOA · Seen Oct 2026
  • Network Endpoint or Cycle BoundaryOA · PHONE SCREEN · Seen Oct 2026
  • Password Clues and the Next CommandOA · Seen Oct 2026
  • Longest Increasing Price SubsequenceOA · Seen Oct 2026
  • Shortest Atom Action PathOA · Seen Oct 2026
  • Simplify a Quadratic ExpressionOA · Seen Oct 2026
  • Minimum-Cost Color SequenceOA · PHONE SCREEN · Seen Oct 2026
  • Largest Microorganism After ConsumptionOA · Seen Oct 2026
  • Invert or Blur an ImageOA · Seen Sep 2026

Similar questions at other companies

  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Beam Search and Nucleus DecodingMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Daily Settlement for Long and Short PositionsBelvedere Trading · OA
  • Sorted Cyclic Shift Difference SumsCapital One · OACapital One interview questions
  • Optimize Package Order by Sorting One WindowAmazon · OA
  • Linear InterpolatorTwo Sigma · OATwo Sigma interview questions

Interview reports that mention this question

  • OpenAI OA: What It Tests (2026)
All OpenAI interview questionsSee OpenAI hiring insights
Saved
class Solution {
    public long macaronOrderPrice(int[] quantities, int unitPrice) {
        
    }
}
Checking account…