Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the 'equal split' strategy in payment splitting?
Equal split means dividing the total amount evenly among all participants, regardless of individual shares or preferences.
Click to reveal answer
beginner
Explain the 'exact split' strategy.
Exact split means each participant pays a specific, predefined amount. The sum of all exact amounts equals the total bill.
Click to reveal answer
beginner
How does the 'percentage split' strategy work?
Percentage split divides the total amount based on each participant's percentage share. The sum of all percentages must be 100%.
Click to reveal answer
intermediate
What is a key challenge when implementing 'exact split' in a system?
Ensuring the sum of all exact amounts matches the total bill exactly, handling rounding errors and validation.
Click to reveal answer
intermediate
Why might 'percentage split' be preferred over 'equal split'?
Percentage split allows flexibility for participants to pay according to their consumption or agreement, unlike equal split which assumes everyone pays the same.
Click to reveal answer
Which split strategy divides the total amount evenly among all participants?
AExact split
BPercentage split
CEqual split
DRandom split
✗ Incorrect
Equal split means everyone pays the same amount.
In which split strategy must the sum of all participant amounts exactly match the total bill?
AExact split
BEqual split
CPercentage split
DProportional split
✗ Incorrect
Exact split requires predefined amounts that sum to the total.
What must the total of all percentages be in a percentage split?
ALess than 100%
BMore than 100%
CAny value
DExactly 100%
✗ Incorrect
Percentages must add up to 100% to cover the whole amount.
Which split strategy offers the most flexibility for different payment shares?
AEqual split
BPercentage split
CFixed split
DExact split
✗ Incorrect
Percentage split allows different shares based on percentages.
What is a common issue when implementing exact split in software?
ARounding errors causing mismatch with total
BParticipants paying too little
CParticipants paying too much
DIgnoring participant preferences
✗ Incorrect
Rounding errors can cause the sum of exact amounts to differ from the total.
Describe the differences between equal, exact, and percentage split strategies.
Think about how the total amount is divided among participants.
You got /4 concepts.
What are key considerations when designing a system to support multiple split strategies?
Consider what can go wrong and how to keep the system reliable.
You got /4 concepts.
Practice
(1/5)
1. Which split strategy divides an amount so that everyone pays the same share regardless of individual preferences?
easy
A. Equal split
B. Exact split
C. Percentage split
D. Random split
Solution
Step 1: Understand the definition of equal split
Equal split means dividing the total amount evenly among all participants.
Step 2: Compare with other splits
Exact split assigns specific amounts, percentage split assigns based on percent, random split is not a standard method.
Final Answer:
Equal split -> Option A
Quick Check:
Equal split = same share for all [OK]
Hint: Equal split means everyone pays the same amount [OK]
2. Which of the following is the correct syntax to represent a percentage split of 40% for user A and 60% for user B in a system design context?
easy
A. {'A': '40%', 'B': '60%'}
B. {'A': 40, 'B': 60}
C. {'A': 0.4, 'B': 0.6}
D. {'A': 4, 'B': 6}
Solution
Step 1: Understand percentage representation in decimals
Percentages are often represented as decimals between 0 and 1 in code for calculations.
Step 2: Evaluate options
{'A': 0.4, 'B': 0.6} uses decimals summing to 1, correct for percentage split. {'A': 40, 'B': 60} uses integers but not decimals. {'A': '40%', 'B': '60%'} uses strings which are not directly usable. {'A': 4, 'B': 6} uses incorrect smaller numbers.
Final Answer:
{'A': 0.4, 'B': 0.6} -> Option C
Quick Check:
Decimal form for percentages = {'A': 0.4, 'B': 0.6} [OK]
Hint: Use decimals (0.4) not integers (40) for percentage splits [OK]
Common Mistakes:
Using integers instead of decimals for percentages
Using strings with % symbol in code
Not ensuring sum equals 1
3. Given a total amount of 100 and a split strategy: {'A': 30, 'B': 70} as exact amounts, what is the amount assigned to user B?
medium
A. 70
B. 100
C. 30
D. 0
Solution
Step 1: Identify the split type and amounts
The split is exact, so amounts are assigned directly as given.
Step 2: Find user B's assigned amount
User B is assigned 70 as per the exact split dictionary.
Final Answer:
70 -> Option A
Quick Check:
Exact split assigns given amounts = 70 [OK]
Hint: Exact split means use given amounts directly [OK]
Common Mistakes:
Adding amounts instead of reading assigned value
Confusing exact with percentage split
Assuming equal split when exact is given
4. In a percentage split system, if the sum of percentages provided is 110%, what is the main issue and how should it be fixed?
medium
A. The sum is valid, no fix needed
B. The sum should be exactly 0%, reset all percentages
C. The sum is less than 100%, add missing percentage
D. The sum exceeds 100%, fix by normalizing percentages to sum to 100%
Solution
Step 1: Identify the problem with sum of percentages
Percentages must sum to 100% (or 1 in decimal) to correctly split amounts.
Step 2: Determine the fix
If sum is 110%, it exceeds total amount. Normalize by scaling percentages so they sum to 100%.
Final Answer:
The sum exceeds 100%, fix by normalizing percentages to sum to 100% -> Option D
Quick Check:
Sum > 100% requires normalization [OK]
Hint: Percentages must sum to 100%, else normalize [OK]
Common Mistakes:
Ignoring sum validation
Assuming sum can be more than 100%
Trying to add missing percentage when sum is too high
5. You need to design a system that supports splitting a bill among users using equal, exact, or percentage strategies. Which approach best ensures scalability and correctness when handling thousands of users?
hard
A. Allow users to input any split without checks and calculate on demand
B. Use a unified split interface that validates input and applies the correct split logic per strategy
C. Store all splits as exact amounts without validation
D. Hardcode equal split only to simplify calculations
Solution
Step 1: Identify requirements for scalability and correctness
System must handle many users and ensure splits are valid and consistent.
Step 2: Evaluate design approaches
Unified interface with validation ensures correctness and flexibility. Hardcoding or no validation risks errors and poor scalability.
Final Answer:
Use a unified split interface that validates input and applies the correct split logic per strategy -> Option B