
Delivering mail across mountains — logistics and optimization.
The Route
Bah Kitbok was the postman of the Khasi Hills. His route covered seven villages spread across the green, misty mountains of Meghalaya, connected by paths so narrow that two people couldn't walk side by side. The total distance, if you measured it on a map, was twenty-two kilometres. But maps don't measure hills. With the climbing and descending, it was closer to thirty.
Bah Kitbok walked this route every day except Sunday. He had walked it for twenty-seven years. His leather bag — stamped with the faded words INDIA POST — had been replaced four times. His shoes had been replaced too many times to count.
He left his home in Laitlyngkot at six every morning, when the clouds were still sleeping in the valleys and the path was wet with overnight rain. By noon, he reached the farthest village, Mawsynram — the wettest place on Earth. By evening, he was home.
"Why don't you retire?" his wife asked. "Your knees hurt. Your bag is too heavy. And it rains every single day."
"Because," said Bah Kitbok, "there are people waiting for letters."
The Letters
Most of the letters Bah Kitbok carried were ordinary. Electricity bills. Bank notices. Government forms printed on thin pink paper. But some were not ordinary at all.
There was the monthly letter from Daia Lyngdoh, a grandmother in Mawsynram, to her grandson studying medicine in Shillong. She couldn't use a phone — her fingers were too stiff for the small buttons — so she dictated letters to the village teacher, who wrote them in neat Khasi script. Bah Kitbok carried these letters down the hill to the post office, and two days later, a medical student in Shillong would open an envelope smelling of wood smoke and turmeric and feel homesick and loved.
There was the quarterly letter from the headman of Nongstoin to the district commissioner, requesting a new school building. The headman had been writing this letter for six years. The school building had not come yet, but the headman kept writing, and Bah Kitbok kept carrying, because giving up was not a word either of them used.
And there was the one letter that Bah Kitbok had been carrying for three months without delivering — because the person it was addressed to had died, and Bah Kitbok couldn't bring himself to return it marked deceased.
The Storm Day
One October morning, a storm hit the Khasi Hills with a fury that bent trees and turned the paths into rivers. The rain fell so hard it hurt the skin. The clouds dropped so low that Bah Kitbok couldn't see ten feet ahead.
His wife blocked the door. "Not today. No one will blame you."
Bah Kitbok looked at his bag. Inside was a letter from a father in Delhi to his daughter in Sohra. The daughter was getting married next week, and the father couldn't come — he worked in a factory and couldn't get leave. The letter was his blessing, his love, his presence at a wedding he would miss.
"That girl needs this letter before her wedding," said Bah Kitbok. "It has her father's words. A father's words on a wedding day are not something that can wait for good weather."
He put on his raincoat — an old plastic sheet tied with rope — picked up his bag, and walked into the storm.
The Delivery
The path was treacherous. Mud slid under his feet. Streams that were usually ankle-deep were now knee-deep. Twice he slipped and caught himself on tree roots. His leather bag, wrapped in three plastic bags, stayed dry.
He reached Sohra at two in the afternoon, soaked through, shivering, his shoes caked in mud so thick they looked like brown boots. He knocked on the door of a small stone house where a young woman was folding wedding clothes.
"Letter for you," said Bah Kitbok, and held out the envelope.
The girl — her name was Banri — opened it right there in the doorway. She read it once, then again, then pressed it against her heart and cried. Not sad tears. Grateful tears. Her father's handwriting. His blessings. His love, carried through a storm by a man who believed that some messages cannot wait.
"Thank you," she whispered.
"It's my job," said Bah Kitbok. But he smiled, because this was the part of the job that no salary could pay for.
The Postman's Creed
Bah Kitbok retired three years later. At his retirement ceremony, the post office gave him a certificate and a shawl. But the real gift came from the seven villages on his route. Each village sent a representative, and each representative read aloud a letter — not a government letter, but a personal one, written by the villagers to their postman.
"Dear Bah Kitbok, you carried our words when the road was broken and the rain was cruel. You are the thread that connected us to the world."
The old postman held the letters in his weathered hands and said, "People think the postal service is about paper and stamps. It isn't. It is about the distance between two people who miss each other. My job was to make that distance shorter. And I did my best."
Today, the villages have mobile phone towers and internet connections. But the oldest residents still write letters — by hand, in Khasi, on lined paper — and send them through the post. Because a letter, they say, carries something a text message never can: the weight of a hand pressing pen to paper, the smell of home, and the knowledge that someone walked through a storm to bring it to you.
The end.
Choose your level. Everyone starts with the story — the code gets deeper as you go.
Here is a taste of what Level 1 looks like for this lesson:
# Nearest-neighbor heuristic for a delivery route
villages = {
"Laitlyngkot": (0, 0), "Cherrapunji": (8, 3),
"Nongstoin": (4, 6), "Sohra": (9, 7),
"Mawsynram": (2, 10), "Nongriat": (6, 4),
}
def distance(a, b):
return ((a[0]-b[0])**2 + (a[1]-b[1])**2) ** 0.5
current = "Laitlyngkot"
route, total = [current], 0
unvisited = set(villages) - {current}
while unvisited:
nearest = min(unvisited, key=lambda v: distance(villages[current], villages[v]))
total += distance(villages[current], villages[nearest])
route.append(nearest)
current = nearest
unvisited.remove(nearest)
print(f"Route: {' -> '.join(route)}")
print(f"Total distance: {total:.1f} units") # Can you beat this?This is just the first of 6 coding exercises in Level 1. By Level 4, you will build: Solve a Hill Town Delivery Route Problem.
Free
Level 0: Listener
Stories, science concepts, diagrams, quizzes. No coding.
You are here
Level 0 is always free. Coding levels (1-4) are part of our 12-Month Curriculum.
Delivering mail across mountains — logistics and optimization.
The big idea: "The Postman of the Hills" teaches us about Logistics & Optimization — and you don't need to write a single line of code to understand it.
Always going to the closest next stop often isn’t the best strategy — it might force a long backtrack. This is a shortest path problem, studied since 1736 when Euler invented graph theory.
Any map becomes a graph: villages are nodes, paths are edges, distances are weights. Finding the optimal route is a classic problem that gets explosively harder with more stops.
Check yourself: For 4 villages, there are 3 possible routes. For 10 villages: 181,440. For 20: over 60 quintillion!
Key idea: Any map can be represented as a mathematical graph. Finding the optimal route gets explosively harder as stops increase.
The TSP asks: visit every node once and return home — what’s the shortest route? For 20 villages, there are more possible routes than the fastest computer could ever check.
So we use heuristics: nearest-neighbor (simple, 20–25% longer than optimal) and 2-opt (swap edges to improve). Amazon, FedEx, and GPS apps all use these.
Predict: A heuristic finds a 420 km route vs 500 km from nearest-neighbor. Is 420 km guaranteed optimal? (No — but it’s much better and found in seconds.)
Key idea: The TSP is computationally unsolvable for large inputs. Heuristic algorithms find near-optimal solutions quickly for real-world routing.
Access all 130+ lessons, quizzes, interactive tools, and offline activities
Every GPS direction uses **Dijkstra’s algorithm**: explore outward from start, always expand the nearest unvisited node, update distances when shorter...
A 5 km trail with a 500m climb might take 3 hours, while an 8 km flat trail takes 1.5 hours. **Uphill walking costs 4x more energy** than flat ground....