In the classic days of Starbucks before these newfangled sticker-printers and wireless drivethrough headset palmtop scanner dealies, in the heady days of 2000-ish, Starbucks had a concise system for describing beverages with a strict syntax and accompanying encoded form.
Vertically on the cup there are a series of labelled boxes which may contain certain values.:
Decaf [ ] -blank- X 1/2 1/3 2/3 Shots [ ] -blank- 0 1 2 3 ... 20 followed by S T G V Syrup [ ] -blank- V M C H Milk [ ] -blank- Wh % N B Custom [ ] -blank- ((-|x)?(F|WC|M|CR) )+ Drink [ ] E EM ECP A L C CM
But we will use a horizontal form for easier manipulation. These are the names of the 6 fields of the input which may be any convenient form. Examples here are simple CSV. The Custom field and Syrup fields each may be a concatenation of several values. You may use any convenient subdelimiter. Examples here use space. The Shots field is also a concatenation of a (possible) number and a designation of the cup size (which is implicit in the physical cup but naturally fits in this place in the encoding).
The Decaf field values are translated into words like this
-blank- -nothing- X "decaf" 1/2 "half-caf" 1/3 "one-third-caf" 2/3 "two-thirds-caf"
Logically, the fractional values are only permissible when the number of shots is divisible by the denominator; but for this challenge it is not necessary to detect or diagnose this error.
The Shots field should be broken into its numerical component (if present) and the size identifier. The number should be displayed in latin tuple form: single, double, triple, quadruple, quintuple, beyond 5 just print the number and the suffix "-tuple" ie.
16-tuple. The size designations are:
S short T tall G grande V venti
2T double tall 3G triple grande
The Syrup field may contain one or more of several optional-number/lettercode tokens. The maximum number of a syrup is 20. Even that is too much. LOL.
V vanilla C caramel M mocha H hazelnut
2V 2C two vanilla two caramel H hazelnut M H 1V mocha hazelnut one vanilla
The Milk field may contain one of the following.
Wh whole-milk % two-percent N skim B breve
The Custom field may contain one or more of several modifiers with optional
x extra F foam - no WC whip M mocha drizzle CR caramel drizzle
The Drink field contains one drink id.
E espresso EM espresso macchiato ECP espresso con panna A americano L latte C cappuccino CM caramel macchiato
Any field may be blank except for the size designation and the drink id.
,3G,V,Wh,,L => triple grande vanilla whole-milk latte X,2T,,N,,L => decaf double tall skim latte 1/2,V,,,,CM => half-caf venti caramel macchiato 2/3,3V,3V,B,WC,L => two-thirds-caf triple venti three vanilla breve whip latte ,G,,,xCR,CM => grande extra caramel drizzle caramel macchiato X,4T,2M 2C,B,xWC -F xM,C => decaf quadruple tall two mocha two caramel breve extra whip no foam extra mocha drizzle cappuccino
There is no need to diagnose erroneous or illogical concoctions such as a "no foam ... cappuccino*.
For only the drinks with the word
espresso, the number
single should be replaced by
double should be replaced by
doppio. And the size may be unspecified and omitted. Also, just for the bare
espresso drink itself, if the only other specification is one of these two specially-replaced numbers-of-shots, then the word
espresso itself should be omitted.
,2,1V,B,,EM => doppio one vanilla breve espresso macchiato ,1,,,,E => solo ,2,,,,E => doppio ,3,,,,E => triple espresso
Additional observations on 'reading a cup'
This part is not a requirement for this challenge but may be a useful refinement in applying this sort of verbalized system in other domains.
I mentioned syntax at the very beginning, and by applying the schema to incoming streams of words, orders could be transmitted verbally by several order takers to the barista making beverages. The rough framework
SIZE .... DRINK provides demarcation between several orders spoken at once. There is thus a tendency to make all the interior attributes as adjectival phrases so the order also has a valid English noun-phrase structure. So
whip is often spoken
with whip or
foam is often spoken
Thus, for some old-time baristas, they're not "correcting you" when they repeat the order in the proper format (well,... sometimes). They're simply organizing the information for the purpose of remembering all the details exactly. By schematizing the information, an entire beverage order becomes a single unit for the purpose of applying the magic number 7 plus or minus 2. So a barista with this skill can hold 5-9 orders in their head provided other distractions do not consume too much head room. :)