// advent-of-postgres/day-22
The Fastest Route
Plan the sleigh's route through the relay stations. The route with the fewest stops is not the fastest one.
Two days to go. The sleigh flies from the North Pole to Oslo through a chain of relay stations, and the route planner broke in the last deploy. Alabaster needs the fastest route by hand.
The relay hops are in hops. Each hop is one way:
| Column | Type | Notes |
|---|---|---|
from_stop |
text |
Where the hop starts |
to_stop |
text |
Where it ends |
minutes |
int |
Flying time for this hop |
The sleigh starts at north-pole and can take any chain of hops. It never needs to visit a station twice.
Your task
What is the shortest total flying time from north-pole to oslo, in minutes?
Submit the number.
Stuck? Show a hint
Build every route with a recursive CTE that carries the total time and an array of visited stops (so it never loops), then take the minimum for oslo.
Download today's data as SQL to solve it on your own Postgres (14 or later).
Solved this puzzle? Share it.
Tag @thedevopsdaily and share it with the community.
We earn commissions when you shop through the links below.
Bitrise
Managed runners for GitHub Actions
Bitrise Build Hub runs your GitHub Actions jobs on M4 Macs and AMD Linux machines. Change runs-on and keep your workflows, secrets and logs on GitHub.
Atomsized
AWS platform engineering and GitOps
Design and automation for reliable AWS and Kubernetes platforms, safer delivery workflows, and preview and UAT environments your engineers can understand and own.
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a Sponsor