Five Quantitative Arithmetic and Algebra Puzzles
Easy · Statistics & Math · Data Scientist · Technical Screen
Problem Statement
Implement solve_quantitative_problems() (taking zero arguments) to compute the exact answers to the five independent quantitative tasks below and return them as a 5-element List[str] in order [task_1, task_2, task_3, task_4, task_5]:
- Length conversion and cutting: A timber trim board measures
4.5yards end to end (1yard =3feet,1foot =12inches). Determine how many full3-inch strips can be cut from the board, formatted as an integer string without decimals (e.g.,"18"). - Compounded percentage moves: An investor acquires
100units of an index fund priced at$100per unit. After the unit price climbs10%, the investor sells50units; afterward, the unit price drops10%from that elevated price, and the investor sells the remaining50units. Compute the gross cash proceeds from that final50-unit sale only, formatted with a leading$and comma thousands separators (omitting.00when exact whole dollars, e.g.,"$1,920"). - Two-denomination note count: A safe deposit pouch holds
160banknotes consisting exclusively of$10bills and$50bills with a combined value of$2,760. Find the exact count of each denomination and format the string strictly as"<X> ten-dollar bills and <Y> fifty-dollar bills". - Remaining evaluation pace: An examiner has
4hours total to score45lab reports and spends30minutes scoring the initial5reports. Compute the average number of minutes remaining per unscored report across the rest of the batch, formatted as"<value> minutes"(plain integer if whole, or exact decimal otherwise, e.g.,"8.5 minutes"). - Scaled sum of squares: Let
m = 1^2 + 2^2 + 3^2 + ... + 512^2. Express the even-square sumS = 2^2 + 4^2 + 6^2 + ... + 1024^2as a constant multiple ofm, formatted as"<k>m".
Examples
The miniature parallel cases below use smaller numbers to illustrate the exact calculation rules and required string formatting without revealing the five target outputs.
Example 1
Miniature Tasks 1-3:
- A 2-yard board (72 inches) cut into 8-inch strips -> 72 // 8 = 9 -> "9"
- 80 fund units bought at $50: +20% -> $60 (sell 40), then -20% -> $48 (sell last 40)
-> 40 * $48 = $1,920 -> "$1,920"
- 10 bills ($10s and $50s) worth $220 -> 7 * $10 + 3 * $50 = $220
-> "7 ten-dollar bills and 3 fifty-dollar bills"
Walk-through: Convert yards to inches (1 yard = 36 inches) before integer floor division; apply the second percentage move to the updated price ($60 * 0.80 = $48, not $50); and verify both bill count (7 + 3 = 10) and dollar sum ($70 + $150 = $220).
Example 2
Miniature Tasks 4-5 & Return Shape:
- 2 hours (120 minutes) for 14 reports, 4 reports done in 35 minutes
-> (120 - 35) / (14 - 4) = 85 / 10 = 8.5 -> "8.5 minutes"
- Let m_small = 1^2 + 2^2 + 3^2 = 14; for triples S_small = 3^2 + 6^2 + 9^2 = 126
-> 126 / 14 = 9 -> "9m"
Call signature:
solve_quantitative_problems() -> [task_1, task_2, task_3, task_4, task_5]
Walk-through: Subtract both elapsed minutes and completed reports before dividing, factor the squared multiplier out of every term in the series, and return a fresh 5-string list on every call.
Constraints
solve_quantitative_problems()accepts0parameters and must return a newList[str]of length5.- Use exact integer or rational arithmetic so floating-point rounding never corrupts formatting checks.
Step-by-step walkthrough
Understand the output contract and why exact fractions help
We need to compute exact solutions to five independent quantitative tasks and return them as a list of five strings in exact order:
Index 0 (Task 1): '54' Index 1 (Task 2): '$4,950' Index 2 (Task 3): '131 ten-dollar bills and 29 fifty-dollar bills' Index 3 (Task 4): '5.25 minutes' Index 4 (Task 5): '4m'Instead of returning hard-coded magic strings, we write one clean, reusable helper function per task so every calculation is transparent and easy to adapt when parameters change (such as the miniature cases in Examples 1 and 2).
Why use
fractions.Fractioninstead of standardfloatarithmetic? Standard floating-point numbers are stored in base 2, so decimals like0.1cannot be represented with complete precision:print(100 * 1.1) # prints 110.00000000000001 instead of 110A
Fraction(numerator, denominator)stores an exact ratio of two integers (Fraction(110, 100)is11/10), so100 * Fraction(110, 100)evaluates toFraction(110, 1)with zero rounding error.Task 1: Convert yards to inches before dividing
Two lengths can only be divided directly once they share a common unit. Here the timber board is given in yards (
4.5yards) while each strip is measured in inches (3inches):1yard =3feet1foot =12inches- Therefore,
1yard =3 * 12 = 36inches
4.5 yards = 4.5 * 36 inches = 162 inches 162 inches // 3 inches/strip = 54 stripsPassing
"4.5"as a string toFraction("4.5")(9/2) and using integer floor division (//) counts only complete strips if any remainder ever occurs.from fractions import Fraction # 1 yard = 3 feet, and 1 foot = 12 inches -> 3 * 12 = 36 inches per yard. INCHES_PER_YARD = 36 def count_strips(board_yards: Fraction, strip_inches: int) -> int: """Task 1: count how many full strips fit inside the board.""" # Convert yards to inches first so both lengths share the exact same unit. board_inches = board_yards * INCHES_PER_YARD # Floor division (//) keeps only complete strips and drops any leftover fraction. return int(board_inches // strip_inches)Task 2: Apply compounded percentage moves sequentially
Notice that Task 2 asks solely for the cash proceeds from the final
50-unit sale, so proceeds from the earlier50-unit sale are not added in — we only need the unit price after both percentage moves.A
+10%climb followed by a-10%drop does not return a$100unit back to$100, because the10%drop is applied to the elevated$110price (just as+20%then-20%on$50in Example 1 lands at$48, not$50):Start: $100 per unit After +10% rise: $100 * (110 / 100) = $110 per unit (first 50 units sold here) After -10% drop: $110 * (90 / 100) = $99 per unit (10% of $110 is $11, not $10!) Final 50 units: 50 * $99 = $4,950from fractions import Fraction def apply_percent_change(price: Fraction, percent_delta: int) -> Fraction: """Multiply price by (100 + percent_delta) / 100 using exact rational math.""" # Example: +10% multiplies by 110/100; -10% multiplies by 90/100. multiplier = Fraction(100 + percent_delta, 100) return price * multiplier def final_batch_proceeds( start_price: int, rise_percent: int, drop_percent: int, units_sold_last: int, ) -> Fraction: """Task 2: compute the cash payout from selling the final batch of units.""" # Phase 1: unit price climbs by rise_percent from the starting price. price_after_rise = apply_percent_change(Fraction(start_price), rise_percent) # Phase 2: the subsequent drop applies to the elevated price, so +10% then -10% does not cancel. price_after_drop = apply_percent_change(price_after_rise, -drop_percent) # Only the units sold in the final batch count toward this task. return price_after_drop * units_sold_lastTask 3: Solve the two-denomination note split via swaps
Let
tensbe the count of$10bills andfiftiesbe the count of$50bills inside the pouch:Equation 1 (total notes): tens + fifties = 160 Equation 2 (total dollars): 10 * tens + 50 * fifties = 2,760Eliminating
tens = 160 - fiftiesmatches a clean swap mental model: 1. Suppose all160notes were$10bills — their combined value would be160 * $10 = $1,600. 2. Reaching$2,760requires$2,760 - $1,600 = $1,160of additional value. 3. Replacing one$10bill with one$50bill keeps the total note count at160while raising the value by$50 - $10 = $40. 4. Adding$1,160takes1,160 / 40 = 29swaps, giving29fifty-dollar bills and160 - 29 = 131ten-dollar bills (131 * $10 + 29 * $50 = $1,310 + $1,450 = $2,760).from typing import Tuple def split_banknotes( note_count: int, total_value: int, small_note: int, large_note: int ) -> Tuple[int, int]: """Task 3: return (small_count, large_count) given total notes and total dollar value.""" # Baseline: imagine every note in the pouch were the smaller denomination ($10). all_small_value = note_count * small_note extra_value_needed = total_value - all_small_value # Each swap from one small note ($10) to one large note ($50) adds ($50 - $10) = $40. value_per_swap = large_note - small_note if value_per_swap <= 0 or extra_value_needed % value_per_swap != 0: raise ValueError("no whole-number note split exists") large_count = extra_value_needed // value_per_swap small_count = note_count - large_count if small_count < 0 or large_count < 0: raise ValueError("no non-negative note split exists") return small_count, large_countTask 4: Divide remaining minutes by remaining reports
To find the average minutes available per unscored report, subtract both the elapsed minutes and the already-scored reports before dividing:
Total window: 4 hours * 60 min/hour = 240 minutes Minutes left: 240 - 30 = 210 minutes Reports left: 45 - 5 = 40 reports Pace available: 210 / 40 = 21 / 4 = 5.25 minutes per reportBecause the initial
5reports took30 / 5 = 6minutes apiece, the examiner must trim the pace to5.25minutes (5minutes15seconds) per report to finish within4hours.from fractions import Fraction def minutes_per_unscored_report( total_hours: int, total_reports: int, reports_scored: int, minutes_spent: int ) -> Fraction: """Task 4: divide remaining available minutes by remaining unscored reports.""" # Subtract both elapsed time and completed reports before dividing. minutes_left = total_hours * 60 - minutes_spent reports_left = total_reports - reports_scored return Fraction(minutes_left, reports_left)Task 5: Factor 2^2 = 4 out of every even square
Align the two series term by term:
m = 1^2 + 2^2 + 3^2 + ... + 512^2 S = 2^2 + 4^2 + 6^2 + ... + 1024^2Both sums contain
512terms, and thek-th term ofSis(2k)^2. Because(a * b)^2 = a^2 * b^2, squaring2ksquares both factors:(2k)^2 = 2^2 * k^2 = 4 * k^2 S = 4*(1^2) + 4*(2^2) + 4*(3^2) + ... + 4*(512^2) = 4 * (1^2 + 2^2 + 3^2 + ... + 512^2) = 4mIn code, summing
mandSoverk = 1..512and formingFraction(s, m)reduces179,481,600 / 44,870,400directly to4, verifying the algebraic factor numerically.from fractions import Fraction def even_squares_ratio(n: int) -> Fraction: """Task 5: compute S / m where m = 1^2 + ... + n^2 and S = 2^2 + 4^2 + ... + (2n)^2.""" # m accumulates 1^2 + 2^2 + ... + n^2; s accumulates (2*1)^2 + (2*2)^2 + ... + (2*n)^2. m = 0 s = 0 for k in range(1, n + 1): m += k * k even_term = 2 * k s += even_term * even_term # Fraction automatically reduces s / m to lowest terms (4 / 1). return Fraction(s, m)Format the exact values to match the output contract
Two small helpers format each exact
Fractioncleanly: -format_number(value)emits integers without.0('54'and'4'), and non-integers as decimals ('5.25'). -format_dollars(value)adds$and comma separators ('$4,950'), using exact integer-cent math whenever cents appear.from fractions import Fraction def format_number(value: Fraction) -> str: """Format whole numbers without '.0' ('54') and fractions as decimals ('5.25').""" if value.denominator == 1: return str(value.numerator) return str(float(value)) def format_dollars(value: Fraction) -> str: """Format exact dollar amounts with commas ('$4,950' or '$4,950.50').""" if value.denominator == 1: return f"${value.numerator:,}" # Convert to integer cents via exact Fraction arithmetic to avoid binary float drift. total_cents = round(value * 100) whole_dollars, cents = divmod(total_cents, 100) return f"${whole_dollars:,}.{cents:02d}"Complete solution
Putting all five helpers and the string formatters together gives the complete implementation:
from typing import Any, Dict, List, Optional, Set, Tuple from fractions import Fraction # 1 yard = 3 feet, and 1 foot = 12 inches -> 3 * 12 = 36 inches per yard. INCHES_PER_YARD = 36 def count_strips(board_yards: Fraction, strip_inches: int) -> int: """Task 1: count how many full strips fit inside the board.""" # Convert yards to inches first so both lengths share the exact same unit. board_inches = board_yards * INCHES_PER_YARD # Floor division (//) keeps only complete strips and drops any leftover fraction. return int(board_inches // strip_inches) def apply_percent_change(price: Fraction, percent_delta: int) -> Fraction: """Multiply price by (100 + percent_delta) / 100 using exact rational math.""" # Example: +10% multiplies by 110/100; -10% multiplies by 90/100. multiplier = Fraction(100 + percent_delta, 100) return price * multiplier def final_batch_proceeds( start_price: int, rise_percent: int, drop_percent: int, units_sold_last: int, ) -> Fraction: """Task 2: compute the cash payout from selling the final batch of units.""" # Phase 1: unit price climbs by rise_percent from the starting price. price_after_rise = apply_percent_change(Fraction(start_price), rise_percent) # Phase 2: the subsequent drop applies to the elevated price, so +10% then -10% does not cancel. price_after_drop = apply_percent_change(price_after_rise, -drop_percent) # Only the units sold in the final batch count toward this task. return price_after_drop * units_sold_last def split_banknotes( note_count: int, total_value: int, small_note: int, large_note: int ) -> Tuple[int, int]: """Task 3: return (small_count, large_count) given total notes and total dollar value.""" # Baseline: imagine every note in the pouch were the smaller denomination ($10). all_small_value = note_count * small_note extra_value_needed = total_value - all_small_value # Each swap from one small note ($10) to one large note ($50) adds ($50 - $10) = $40. value_per_swap = large_note - small_note if value_per_swap <= 0 or extra_value_needed % value_per_swap != 0: raise ValueError("no whole-number note split exists") large_count = extra_value_needed // value_per_swap small_count = note_count - large_count if small_count < 0 or large_count < 0: raise ValueError("no non-negative note split exists") return small_count, large_count def minutes_per_unscored_report( total_hours: int, total_reports: int, reports_scored: int, minutes_spent: int ) -> Fraction: """Task 4: divide remaining available minutes by remaining unscored reports.""" # Subtract both elapsed time and completed reports before dividing. minutes_left = total_hours * 60 - minutes_spent reports_left = total_reports - reports_scored return Fraction(minutes_left, reports_left) def even_squares_ratio(n: int) -> Fraction: """Task 5: compute S / m where m = 1^2 + ... + n^2 and S = 2^2 + 4^2 + ... + (2n)^2.""" # m accumulates 1^2 + 2^2 + ... + n^2; s accumulates (2*1)^2 + (2*2)^2 + ... + (2*n)^2. m = 0 s = 0 for k in range(1, n + 1): m += k * k even_term = 2 * k s += even_term * even_term # Fraction automatically reduces s / m to lowest terms (4 / 1). return Fraction(s, m) def format_number(value: Fraction) -> str: """Format whole numbers without '.0' ('54') and fractions as decimals ('5.25').""" if value.denominator == 1: return str(value.numerator) return str(float(value)) def format_dollars(value: Fraction) -> str: """Format exact dollar amounts with commas ('$4,950' or '$4,950.50').""" if value.denominator == 1: return f"${value.numerator:,}" # Convert to integer cents via exact Fraction arithmetic to avoid binary float drift. total_cents = round(value * 100) whole_dollars, cents = divmod(total_cents, 100) return f"${whole_dollars:,}.{cents:02d}" def solve_quantitative_problems() -> List[str]: # Compute each task's exact numeric answer first, then format into the required strings. strips = count_strips(Fraction("4.5"), 3) proceeds = final_batch_proceeds(100, 10, 10, 50) tens, fifties = split_banknotes(160, 2760, 10, 50) per_report = minutes_per_unscored_report(4, 45, 5, 30) ratio = even_squares_ratio(512) return [ str(strips), format_dollars(proceeds), f"{tens} ten-dollar bills and {fifties} fifty-dollar bills", f"{format_number(per_report)} minutes", f"{format_number(ratio)}m", ]✅ Submit now — all tests should pass.
Intuition & how it works
Think of quantitative tasks like laboratory measurements where every quantity carries an explicit unit or baseline — yards vs. inches, dollars per fund unit, banknotes in a pouch, or minutes left on a timer. Almost every arithmetic slip comes from dividing mismatched units or applying a percentage move to an outdated base. Our approach writes one focused helper function per task and carries out every calculation with exact rational arithmetic (fractions.Fraction, which represents a value as an exact numerator / denominator ratio of integers rather than an approximate binary decimal).
Why do quick mental shortcuts or standard floating-point (float) math trip people up? Gut instinct suggests "+20% followed by -20% brings $50 back to $50" or "multiplying each term inside a sum of squares by 3 triples the sum to 3m," missing how multiplicative factors compound (1.20 * 0.80 = 0.96, and (3k)^2 = 9k^2). Meanwhile, binary float arithmetic only approximates decimal tenths (100 * 1.1 produces 110.00000000000001), which can break integer-denominator checks when formatting clean output strings.
Let's walk through the miniature parallel tasks from Examples 1 and 2 to see each rule in action:
1. Unit conversion: 2 yd * 36 in/yd = 72 in -> 72 // 8 = 9 -> "9"
2. Compounded % moves: $50 * (120/100) = $60 -> $60 * (80/100) = $48 -> 40 * $48 = "$1,920"
3. Banknote swaps: 10 * $10 = $100 base; need +$120 at +$40/swap -> 3 $50s, 7 $10s
4. Remaining pace: (120 - 35) min / (14 - 4) reports = 85 / 10 = "8.5 minutes"
5. Factoring squares: 3^2 + 6^2 + 9^2 = 9 * (1^2 + 2^2 + 3^2) -> "9m"
Applying the exact same helpers to the five target tasks produces ['54', '$4,950', '131 ten-dollar bills and 29 fifty-dollar bills', '5.25 minutes', '4m'].
Complexity
- Time:
O(1)for Tasks 1–4, andO(n)for Task 5's numerical check (O(1)algebraically). Tasks 1 through 4 each perform a constant number of integer andFractionoperations regardless of input magnitudes. In Task 5,even_squares_ratio(n)loopsn = 512iterations to confirmS / m = 4directly on the actual sums, though factoring4out of(2k)^2 = 4k^2determines the answer on paper inO(1)constant time. - Space:
O(1). Only a constant number of integer andFractionvalues exist in memory at once, alongside the 5-element output list.
Edge cases
- Lengths that leave a partial remainder: Using floor division (
//, which divides and rounds down to the nearest whole integer) ensures a 10-inch board cut into 3-inch strips reports3full strips rather than3.33. - Dollar payouts with cents: Whenever unit prices and counts yield non-zero cents (such as
$4,950.50),format_dollarsconvertsvalue * 100to integer cents via exactFractionrounding rather thanfloat, preventing binary drift. - Infeasible banknote totals: If the surplus above
note_count * small_noteis not divisible bylarge_note - small_note, or falls outside[160 * $10, 160 * $50], no valid non-negative integer split exists andsplit_banknotesraisesValueError. - Zero remaining reports: When
reports_scored == total_reports,reports_leftis0and the pace per unscored report is undefined (ZeroDivisionErrorinFraction).
Common mistakes
- Skipping half of the yard-to-inch conversion (Task 1): Dividing
4.5 / 3 = 1.5without converting units, or multiplying by3feet/yard (13.5) while forgetting12inches/foot. - Treating
+10%and-10%as cancelling out (Task 2): Answering$5,000(50 * $100), or returning the first batch ($5,500) or total cash across all 100 units ($10,450). - Reversing the two denominations in the formatted string (Task 3): Computing
fifties = 29first and accidentally formatting"29 ten-dollar bills and 131 fifty-dollar bills"without checking10 * tens + 50 * fifties == 2,760. - Dividing by total reports or full window time (Task 4): Computing
210 / 45 = 4.67(remaining minutes over all reports) or240 / 45 = 5.33(initial budget per report). - Forgetting to square the factor of
2(Task 5): Answering2minstead of4mbecause(2k)^2 = 4k^2, or mistakingSfor the sum of all squares up to1024^2.
Follow-up questions
-
In Task 2, would the payout on the final 50 units change if the 10% drop happened before the 10% rise? Multiplication is commutative (
a * b == b * a), so$100 * 0.90 * 1.10still lands at$99per unit and the final 50 units still bring in$4,950. However, the first 50 units would have been sold at$90($4,500) instead of$110($5,500), lowering combined proceeds across all 100 units from$10,450to$9,450. -
How could you solve Task 3's banknote split in code without setting up linear equations? Because there are only
160notes in total, a simple loop testing every candidate counttensfrom0through160(settingfifties = 160 - tensand checking10 * tens + 50 * fifties == 2760) runs at most161iterations and finds(131, 29)immediately. The swap formula reaches the same answer inO(1)time even if there were10^9notes. -
In Task 4, if the examiner maintained the initial 30-minute pace for all 45 reports, by how many minutes would they miss the 4-hour window? Scoring
5reports in30minutes equals6minutes per report. At6minutes per report, all45reports require45 * 6 = 270minutes (4.5hours), exceeding the4-hour (240-minute) allotment by30minutes. -
How does Task 5's scaling identity generalize when every base integer is multiplied by an arbitrary constant c and raised to power p? Because
(c * k)^p = (c^p) * (k^p), the constant factorc^pfactors cleanly out of every term in the sum. For instance,3^2 + 6^2 + ... + (3 * 512)^2 = 3^2 * m = 9m(as in Example 2), while2^3 + 4^3 + ... + (2 * 512)^3equals2^3(8) times1^3 + 2^3 + ... + 512^3.
Follow-up questions
- In Task 2, would the payout on the final 50 units change if the 10% drop happened before the 10% rise?
- How could you solve Task 3's banknote split in code without setting up linear equations?
- In Task 4, if the examiner maintained the initial 30-minute pace for all 45 reports, by how many minutes would they miss the 4-hour window?
- How does Task 5's scaling identity generalize when every base integer is multiplied by an arbitrary constant c and raised to power p?
Similar questions
- Handling an Inconclusive A/B Test Readout
- Ad Serving Economics, Mixture Variance, and Waiting Times
- Target Bankroll Probability with Biased Flips
- Statistical Inference and Sizing for Trip Cancellations
- Impact of Dataset Duplication on OLS and Large-Sample Inference
- Three-Dice Product Distribution and Quoting Risk