HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /Nine houses stand along a straight road at the marks 1, 2, 3, …, 9 km…
HardMathematicsHigh School (11–12)Inequalities and the AM, GM and HM MeansNumericalOlympiad

Nine houses stand along a straight road at the marks 1, 2, 3, …, 9 km…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

Nine houses stand along a straight road at the marks 1,2,3,…,91, 2, 3, \dots, 91,2,3,…,9 km. A village council wants to dig one well at a point xxx km on the road so that the total walking distance

D(x)=∣x−1∣+∣x−2∣+⋯+∣x−9∣\displaystyle D(x) = |x - 1| + |x - 2| + \dots + |x - 9|D(x)=∣x−1∣+∣x−2∣+⋯+∣x−9∣

is as small as possible.

  1. Pair the houses from the outside in, and use the triangle inequality on each pair.
  1. Find the best place for the well and the least total distance.
  1. A tenth house is built at 101010 km. Where may the well go now, and what is the new least total distance?

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

km
km
Need a reminder? The key ideaShowHide

The triangle inequality ∣a+b∣≤∣a∣+∣b∣|a + b| \le |a| + |b|∣a+b∣≤∣a∣+∣b∣; a quadratic ax2+bx+cax^2 + bx + cax2+bx+c with a>0a > 0a>0 is never negative exactly when

b2−4ac ≤ 0.\displaystyle b^2 - 4ac \ \le\ 0.b2−4ac ≤ 0.

The worked solution

Check an answer or open a hint to unlock the worked solution.

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Plan. Pair the outer houses; the middle one decides.

Step 1. The pairs. ∣x−k∣+∣x−(10−k)∣≥10−2k|x - k| + |x - (10 - k)| \ge 10 - 2k∣x−k∣+∣x−(10−k)∣≥10−2k for k=1,2,3,4k = 1, 2, 3, 4k=1,2,3,4, with equality when xxx lies between kkk and 10−k10 - k10−k. The bounds are 8,6,4,28, 6, 4, 28,6,4,2 km.

Step 2. The middle. ∣x−5∣≥0|x - 5| \ge 0∣x−5∣≥0, with equality at x=5x = 5x=5.

Step 3. Nine houses. D(x)≥8+6+4+2=20D(x) \ge 8 + 6 + 4 + 2 = 20D(x)≥8+6+4+2=20 km, at x=5x = 5x=5 km, the median.

Step 4. Ten houses. Pair 111 with 101010, 222 with 999, and so on: the bounds are 9+7+5+3+1=259 + 7 + 5 + 3 + 1 = 259+7+5+3+1=25 km, reached for any xxx from 555 to 666 km.

Answer: 202020 km at 555 km; with ten houses, 252525 km anywhere between 555 and 666 km.

Log in to save this for later
← All Problems
← Real numbers x, y and z satisfy x + y + z = 5 and xy + yz + zx = 3.…The equation x⁴ - 12x³ + ax² - bx + 81 = 0; has four positive real roots… →
More onInequalities and the AM, GM and HM Means

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. The triangle inequality and polynomial boundsConvexity, Jensen and Inequality Techniques

More on this topic

  1. The equation x⁴ - 12x³ + ax² - bx + 81 = 0; has four positive real roots…Advanced
  2. Real numbers x, y and z satisfy x + y + z = 5 and xy + yz + zx = 3.…Hard
  3. Real numbers x and y satisfy x² + xy + y² = 3.…Advanced
  4. Schur's inequality says that for non-negative a, b, c, a(a - b)(a - c) + b(b - a)(b - c) + c(c…
Advanced
  • The identity a³ + b³ + c³ - 3abc; = (a + b + c) · 1/2big[(a - b)²; + (b - c)² + (c - a)²big]; holds…Hard
  • All problems on this topic →