Welcome to Use Grouping to Represent Structure! So far, you have translated single-operation phrases into expressions and then combined two operations into one compact form. Both of those skills come into play today.
This lesson focuses on a question that changes the meaning of an expression more than most people expect: which part of the calculation should happen first? Imagine you are ordering lunch for a group. Each person gets a sandwich that costs $6 and a drink that costs $2. There are 4 people. You would probably think: "Each meal is $8, so the total is $32." Without even realizing it, you grouped the sandwich and the drink into a single per-person cost before multiplying by the number of people. That mental grouping is exactly what parentheses do — they tell anyone reading the expression, "Handle this part first." By the end of this lesson, you will be able to:
Understand how parentheses change the meaning of an expression by controlling the order of operations.
Recognize the "repeated combo" pattern where a combined amount applies to every unit in a group.
Apply an extended three-step process (list, identify what repeats, write) to accurately build grouped expressions.
Why Parentheses Change the Meaning 🧮
Spotting the "Repeated Combo" Pattern 🍱
Grouped vs. Ungrouped: A Side-by-Side Look ⚖️
Writing Grouped Expressions Step by Step ✍️
Conclusion and Next Steps
In this lesson, you learned that parentheses control which part of an expression is calculated first and that choosing whether or not to group can completely change what a model represents. You focused on the repeated combo pattern, where a sum or difference applies to every unit in a group and must be enclosed in parentheses before being multiplied. You also extended our three-step process to include identifying the grouped sub-expression, and you compared grouped versus ungrouped forms side by side to see exactly how the meaning shifts.
Now it is time to put this skill to work. In the upcoming exercises, you will pick the correctly grouped expression, fill in missing pieces, write your own grouped expressions from scratch, and even explain to a friend why parentheses matter. Let's jump in and make grouping second nature!
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal
As you may recall from earlier math classes, multiplication is performed before addition when no grouping symbols are present. This rule, often called the order of operations, means that the way we write an expression determines which calculation happens first.
Look at two expressions that use the same numbers and operations but have very different meanings:
6+2×4(6+2)×4
In the first expression, multiplication happens before addition: 2×4=8, then 6+8=14.
In the second expression, the parentheses force the addition to happen first: 6+2=8, then 8×4=32.
Same numbers, same operations, but the results are 14 and 32 — and in a real-world scenario that difference could mean charging the wrong amount or ordering the wrong quantity.
The most common situation that calls for parentheses is what we can call the repeated combo pattern. It appears whenever a combined amount applies to every unit in a group. Here is a clear example:
Each gift bag contains a toy costing c dollars and a $3 card. You prepare 8 bags.
Let's think through this. Every single bag holds the same combination: a toy plus a card. The per-bag cost is c+3. Because that combined cost repeats 8 times, we multiply the whole combo by 8:
8⋅(c+3)
The parentheses tell us to treat c+3 as one quantity before multiplying. Without them, the expression 8⋅c+3 would mean "8 toys plus one $3 card," which is not the same situation at all.
Here are a couple more examples of the same pattern:
Situation
Per-unit combo
Units
Expression
Sandwich (s) and $3 drink, ordered for 5 coworkers
s+3
5
5⋅(s+3)
Base ticket price (p) plus $4 service fee, for n people
p+4
n
n⋅(p+4)
A snack (a) and a $2 bottle of water, for each of n hikers
a+2
n
n⋅(a+2)
Notice the common thread: when a sum (or difference) is repeated across multiple units, that sum needs parentheses before it is multiplied.
Seeing both versions next to each other is one of the best ways to build intuition. Let's revisit the ticket example from the table above and compare:
With grouping:n⋅(p+4) means "each person pays the ticket price plus the fee, and we multiply that total per-person cost by the number of people."
Without grouping:n⋅p+4 means "multiply the ticket price by the number of people, and then add one single $4 fee at the end."
If there are 3 people and the base ticket price is $20:
Expression
Calculation
Result
n⋅(p+4)
3⋅(20+4)=3⋅24
72
n⋅p+4
3⋅20+4=60+4
64
The first expression correctly charges the fee to every person. The second charges it only once. Choosing the wrong form means the model does not match the situation.
In the previous lesson we used a three-step process — list, determine, assemble — to build multi-step expressions. We can extend that process to handle grouping by sharpening the second step:
List each quantity. Write down every number and variable, just as before.
Identify what repeats as a unit. Ask yourself: Is there a combined amount that applies to every item, person, or group? If yes, that combined amount is your grouped sub-expression.
Write the expression with parentheses. Place parentheses around the sub-expression that must be calculated first, then apply the outer operation.
Let's apply this to a new scenario:
A group of g friends each pays a $12 cover charge plus a $5 coat check fee at a venue.
Identify what repeats: every friend pays the same combined cost of 12+5.
Write:
g⋅(12+5)
The parentheses make it clear that each friend pays both fees, and we multiply the total per-person cost by the number of friends. This ensures the addition happens first to find the single "per-person" value before the multiplication scales it up for the entire group.
A few pitfalls come up regularly when working with grouping. Keeping them in mind will help you avoid errors as you practice.
Forgetting parentheses when a sum is multiplied. Writing g⋅12+5 instead of g⋅(12+5) changes the meaning from "everyone pays both fees" to "everyone pays the cover, and then a single coat check fee is added once."
Adding parentheses where they are not needed. If only one term is being multiplied, parentheses do not change anything. For instance, 5+3n already means "5 plus 3 times n" because multiplication happens before addition by default. Writing 5+(3⋅n) is not wrong, but the parentheses are unnecessary.
Grouping the wrong part. Always go back to the situation and ask which quantities form the repeated combo. The parentheses should wrap exactly that combo and nothing else.
When in doubt, plug in a small number and check whether the result makes sense in the real-world context. If the total seems too low or too high, the grouping may be off.