KatInterview

Five Quick Quantitative Puzzles with Exact String Answers

Math & Bit ManipulationAuto-graded · 2 test cases
EasyAuto-gradedMath & Bit Manipulationmatharithmeticalgebra

Last updated

Solve five short arithmetic and algebra puzzles (units, compounding percentages, linear system, rate, series scaling) and return them in an exact string format.

Five Quick Quantitative Puzzles

Write a function that takes no arguments and returns a list of exactly five strings. Entry i (0-indexed) is the answer to puzzle i + 1 below. The puzzles are independent of each other.

Puzzles

  1. Cutting a rope. A rope is 4.5 yards long. It is cut into pieces that are each 3 inches long, with nothing left over. How many pieces are there?
  2. Share trade. Sam buys 100 shares at $100 each. The price goes up by 10%, and Sam sells 50 shares. The new price then falls by 10% of the raised price, and Sam sells his other 50 shares at that lower price. How much money does Sam receive for the second batch of 50 shares?
  3. Cash drawer. A drawer holds 160 bills. Each bill is either a $10 or a $50, and together they are worth $2,760. How many bills of each kind are there?
  4. Grading time. A teacher has 4 hours in total to grade 45 papers. The first 5 papers take her 30 minutes. If she splits the leftover time evenly, how many minutes can she spend on each of the remaining papers?
  5. Scaling a sum of squares. Let m = 1^2 + 2^2 + ... + 512^2. Express S = 2^2 + 4^2 + 6^2 + ... + 1024^2 in terms of m.

Required output format

The returned list must contain these five strings, with exactly this formatting:

IndexFormat
0The integer count as plain digits, with no units
1A dollar sign, then the amount with a comma as the thousands separator, and no decimals
2"<t> ten-dollar bills and <f> fifty-dollar bills", where <t> and <f> are the counts
3The number of minutes as a decimal (no trailing zeros beyond what is needed), followed by a space and the word minutes
4The coefficient immediately followed by the letter m (for example, 7m)

Comparison is by exact string match, so spacing, punctuation, and lowercase letters matter.

Constraints

  • The function takes no parameters.
  • The return value is a List[str] of length 5.
  • All numbers are fixed by the puzzles above; there is no input to read.
  • Percentage changes compound: the second change applies to the already-changed price.

Examples

Example 1

Input: answer_five_puzzles()

Output: ['54', '$4,950', '131 ten-dollar bills and 29 fifty-dollar bills', '5.25 minutes', '4m']

Hints

Hint 1

Convert every length to the same unit first: one yard is 36 inches, so you can count pieces by dividing total inches by 3.

Hint 2

For the share puzzle, the second 10% change is taken from the raised price, not the original one, so the multipliers are 1.10 and then 0.90. For the drawer, try assuming all 160 bills are $10s and see how much value is missing; each swap to a $50 adds $40.

Hint 3

For the sum of even squares, write each term as (2k)^2 with k running from 1 to 512, then factor out the constant. For the grading puzzle, subtract both the time and the papers already used before dividing.