Hi nightwalkeuv,Your instinct about the range is completely correct: inside
any single valid set, the biggest and smallest members can differ by exactly
16, never more. That constraint is real and it never gets broken. So you're not making an error about the range itself.
The trick is in what the question is actually asking. Look at the wording:
"the difference between the largest and smallest possible integers that could be members of S"That word
possible is doing everything. It's not asking for the range of one set. It's asking two separate questions:
- Across
every set that fits all four conditions, what's the highest value any member could ever reach? -
30- Across
every set that fits all four conditions, what's the lowest value any member could ever reach? -
2Those two extremes come from
two different sets, and that's allowed. In Chetan's constructions, each set on its own has range
16:
- Set with the max: seven 14s, eight 16s, one
30 - range =
30 -
14 =
16 ✓
- Set with the min: one
2, eight 16s, seven 18s - range =
18 -
2 =
16 ✓
So neither set violates the range rule. We just harvest the ceiling (
30) from one and the floor (
2) from the other, and the answer reports the gap between those two:
30 -
2 =
28.
A simpler version to lock it in. Suppose I ask: "For a set of two integers with range
3, what's the largest and smallest possible member?" One valid set is {
2,
5}; another is {
100,
103}. No single set has a spread bigger than
3 - but the smallest member you could ever see is unbounded low, and the largest unbounded high. The "possible members" question ranges over
all valid sets, not one.
Your range logic was right the whole time - it just answers a different question than the one asked.
Answer: Dnightwalkeuv
When range is 16 how can the difference between smallest and largest be greater than 16