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]:

  1. Length conversion and cutting: A timber trim board measures 4.5 yards end to end (1 yard = 3 feet, 1 foot = 12 inches). Determine how many full 3-inch strips can be cut from the board, formatted as an integer string without decimals (e.g., "18").
  2. Compounded percentage moves: An investor acquires 100 units of an index fund priced at $100 per unit. After the unit price climbs 10%, the investor sells 50 units; afterward, the unit price drops 10% from that elevated price, and the investor sells the remaining 50 units. Compute the gross cash proceeds from that final 50-unit sale only, formatted with a leading $ and comma thousands separators (omitting .00 when exact whole dollars, e.g., "$1,920").
  3. Two-denomination note count: A safe deposit pouch holds 160 banknotes consisting exclusively of $10 bills and $50 bills 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".
  4. Remaining evaluation pace: An examiner has 4 hours total to score 45 lab reports and spends 30 minutes scoring the initial 5 reports. 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").
  5. Scaled sum of squares: Let m = 1^2 + 2^2 + 3^2 + ... + 512^2. Express the even-square sum S = 2^2 + 4^2 + 6^2 + ... + 1024^2 as a constant multiple of m, 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() accepts 0 parameters and must return a new List[str] of length 5.
  • Use exact integer or rational arithmetic so floating-point rounding never corrupts formatting checks.

Step-by-step walkthrough

  1. 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.Fraction instead of standard float arithmetic? Standard floating-point numbers are stored in base 2, so decimals like 0.1 cannot be represented with complete precision:

    print(100 * 1.1)  # prints 110.00000000000001 instead of 110
    

    A Fraction(numerator, denominator) stores an exact ratio of two integers (Fraction(110, 100) is 11/10), so 100 * Fraction(110, 100) evaluates to Fraction(110, 1) with zero rounding error.

  2. 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.5 yards) while each strip is measured in inches (3 inches):

    • 1 yard = 3 feet
    • 1 foot = 12 inches
    • Therefore, 1 yard = 3 * 12 = 36 inches
    4.5 yards  =  4.5 * 36 inches  =  162 inches
    162 inches // 3 inches/strip   =  54 strips
    

    Passing "4.5" as a string to Fraction("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)
    
  3. 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 earlier 50-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 $100 unit back to $100, because the 10% drop is applied to the elevated $110 price (just as +20% then -20% on $50 in 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,950
    
    from 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_last
    
  4. Task 3: Solve the two-denomination note split via swaps

    Let tens be the count of $10 bills and fifties be the count of $50 bills inside the pouch:

    Equation 1 (total notes):   tens + fifties = 160
    Equation 2 (total dollars): 10 * tens + 50 * fifties = 2,760
    

    Eliminating tens = 160 - fifties matches a clean swap mental model: 1. Suppose all 160 notes were $10 bills — their combined value would be 160 * $10 = $1,600. 2. Reaching $2,760 requires $2,760 - $1,600 = $1,160 of additional value. 3. Replacing one $10 bill with one $50 bill keeps the total note count at 160 while raising the value by $50 - $10 = $40. 4. Adding $1,160 takes 1,160 / 40 = 29 swaps, giving 29 fifty-dollar bills and 160 - 29 = 131 ten-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_count
    
  5. Task 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 report
    

    Because the initial 5 reports took 30 / 5 = 6 minutes apiece, the examiner must trim the pace to 5.25 minutes (5 minutes 15 seconds) per report to finish within 4 hours.

    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)
    
  6. 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^2
    

    Both sums contain 512 terms, and the k-th term of S is (2k)^2. Because (a * b)^2 = a^2 * b^2, squaring 2k squares 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)
      = 4m
    

    In code, summing m and S over k = 1..512 and forming Fraction(s, m) reduces 179,481,600 / 44,870,400 directly to 4, 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)
    
  7. Format the exact values to match the output contract

    Two small helpers format each exact Fraction cleanly: - 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}"
    
  8. 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, and O(n) for Task 5's numerical check (O(1) algebraically). Tasks 1 through 4 each perform a constant number of integer and Fraction operations regardless of input magnitudes. In Task 5, even_squares_ratio(n) loops n = 512 iterations to confirm S / m = 4 directly on the actual sums, though factoring 4 out of (2k)^2 = 4k^2 determines the answer on paper in O(1) constant time.
  • Space: O(1). Only a constant number of integer and Fraction values 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 reports 3 full strips rather than 3.33.
  • Dollar payouts with cents: Whenever unit prices and counts yield non-zero cents (such as $4,950.50), format_dollars converts value * 100 to integer cents via exact Fraction rounding rather than float, preventing binary drift.
  • Infeasible banknote totals: If the surplus above note_count * small_note is not divisible by large_note - small_note, or falls outside [160 * $10, 160 * $50], no valid non-negative integer split exists and split_banknotes raises ValueError.
  • Zero remaining reports: When reports_scored == total_reports, reports_left is 0 and the pace per unscored report is undefined (ZeroDivisionError in Fraction).

Common mistakes

  • Skipping half of the yard-to-inch conversion (Task 1): Dividing 4.5 / 3 = 1.5 without converting units, or multiplying by 3 feet/yard (13.5) while forgetting 12 inches/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 = 29 first and accidentally formatting "29 ten-dollar bills and 131 fifty-dollar bills" without checking 10 * 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) or 240 / 45 = 5.33 (initial budget per report).
  • Forgetting to square the factor of 2 (Task 5): Answering 2m instead of 4m because (2k)^2 = 4k^2, or mistaking S for the sum of all squares up to 1024^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.10 still lands at $99 per 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,450 to $9,450.

  • How could you solve Task 3's banknote split in code without setting up linear equations? Because there are only 160 notes in total, a simple loop testing every candidate count tens from 0 through 160 (setting fifties = 160 - tens and checking 10 * tens + 50 * fifties == 2760) runs at most 161 iterations and finds (131, 29) immediately. The swap formula reaches the same answer in O(1) time even if there were 10^9 notes.

  • 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 5 reports in 30 minutes equals 6 minutes per report. At 6 minutes per report, all 45 reports require 45 * 6 = 270 minutes (4.5 hours), exceeding the 4-hour (240-minute) allotment by 30 minutes.

  • 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 factor c^p factors 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), while 2^3 + 4^3 + ... + (2 * 512)^3 equals 2^3 (8) times 1^3 + 2^3 + ... + 512^3.

Follow-up questions

Similar questions

More BlackEdge interview questions

All 1 BlackEdge questions →