Problem #53 MEDIUM
The Spice Merchant's Weights
Scenario Number Theory Logic Deduction
Problem Statement
What are the four weight values that allow Ibrahim to measure every integer from 1 to 40 grams using a balance scale, where weights can be placed on either pan?
Answer & Quick Explanation
Think you've got it? Click below to check your answer.
The four weights are 1, 3, 9, and 27 grams. Placing weights on either pan of the balance scale creates a ternary system covering all integers from 1 to 40. Formula: k weights (powers of 3) cover 1 to (3^k - 1)/2.
Detailed Editorial Solution
Want to see the step-by-step breakdown? Click below to reveal the editorial.
When a weight can be on the left pan (positive), the right pan (negative), or not used (zero), it contributes three states. This is exactly base-3 representation. To cover 1 through N with k weights, use powers of 3: 1, 3, 9, 27, ... The total coverage is (3^k - 1)/2.
Step 1: With one side only (binary): weights 1, 2, 4, 8 cover 1-15. Each weight is double the previous.
Step 2: With both sides (ternary): each weight w can contribute +w (on opposite pan), -w (on same pan as item), or 0 (not used). This is a balanced ternary system.
Step 3: Weight 1: can measure 0 or 1. Weight 3: combined with 1, can measure 1+3=4, 3-1=2, 3 alone, 1 alone. Covers 1, 2, 3, 4.
Step 4: Weight 9: combined with {1,3}, can measure 9-3-1=5, 9-3=6, 9-3+1=7, 9-1=8, 9, 9+1=10, 9+3-1=11, 9+3=12, 9+3+1=13. Covers 1-13.
Step 5: Weight 27: combined with {1,3,9}, covers up to 27+9+3+1=40. Covers 1-40.
Step 6: The formula: k weights of values 1, 3, 9, ... 3^(k-1) cover all integers from 1 to (3^k - 1)/2. For k=4: (81-1)/2 = 40. Perfect.
Key Insight:
The ternary system doubles the efficiency of binary for physical weights. While binary (one-sided) weights grow as powers of 2, ternary (two-sided) weights grow as powers of 3 — a much faster expansion. The balance scale's two pans are the physical realisation of positive, negative, and zero in balanced ternary.