<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/when-will-that-elevator-arrive-elevator-dispatching-yk1fmmihm" -->

---
title: When will that elevator arrive? Elevator dispatching
description: Picking the closest elevator by floor count can send you the wrong one, because it ignores direction. The post simulates a 23-floor building with 6 elevators...
canonical: https://daily.dev/posts/when-will-that-elevator-arrive-elevator-dispatching-yk1fmmihm
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: When will that elevator arrive? Elevator dispatching | daily.dev
og:description: Picking the closest elevator by floor count can send you the wrong one, because it ignores direction. The post simulates a 23-floor building with 6 elevators...
og:url: https://daily.dev/posts/when-will-that-elevator-arrive-elevator-dispatching-yk1fmmihm
og:image: https://api.daily.dev/og/posts/yk1fMMIhm.png
og:image:alt: When will that elevator arrive? Elevator dispatching
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# When will that elevator arrive? Elevator dispatching

**[R-bloggers](https://daily.dev/sources/rbloggers)** · 7 min read · 0 upvotes · 0 comments

## Summary

Picking the closest elevator by floor count can send you the wrong one, because it ignores direction. The post simulates a 23-floor building with 6 elevators and 5 waiting passengers in R. A nearest-elevator rule assigns you on floor 11 to Elevator 5 on floor 10, regardless of direction. An estimated-time-of-arrival rule adds direction and a 2-second turnaround penalty. It picks Elevator 3, already heading down, which arrives in 3 seconds. More sophisticated systems use dynamic group control that may revise assignments as calls change.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.r-bloggers.com/2026/11/when-will-that-elevator-arrive-elevator-dispatching>

## Questions this post answers

### Why is assigning the nearest elevator by floor distance a poor dispatching algorithm?

A nearest-elevator rule ignores direction, so an elevator one floor away but moving the wrong way may take longer than one farther off already heading toward you. In a 23-floor, 6-elevator simulation, an ETA approach that adds a 2-second turnaround penalty picked an elevator on floor 14 reaching floor 11 in 3 seconds instead.

_Developers exploring algorithm trade-offs like this follow simulation and scheduling ideas on daily.dev._

### How do I estimate an elevator's arrival time in R when accounting for direction and turnaround?

Compute time per elevator from its floor, direction and destination at one floor per second. A stationary elevator takes the floor distance. An up-moving elevator for a down request must finish its trip, reverse and return, adding a 2-second turnaround penalty. A down-moving elevator above the passenger takes the straight floor difference. Assign each passenger to the minimum estimated time.

_daily.dev keeps R and algorithm-simulation techniques like this within reach as you learn._

## Similar posts on daily.dev

- [Elevators](https://daily.dev/posts/elevators-20yf85gde) · Hacker News · 0 upvotes · 0 comments
- [Google Interview Question: First Train Is the Wrong Train](https://daily.dev/posts/google-interview-question-first-train-is-the-wrong-train-x881fq9wi) · Medium · 5 upvotes · 1 comments
- [Racing Trains](https://daily.dev/posts/racing-trains-i3xkmsxov) · The Daily WTF · 0 upvotes · 0 comments
- [Forecasting Models to Improve Driver Availability at Airports](https://daily.dev/posts/forecasting-models-to-improve-driver-availability-at-airports-y5uoudppc) · Programming Digest · 1 upvotes · 0 comments
- [DoorDash Dispatch: Building a Lightning-Fast Delivery System](https://daily.dev/posts/doordash-dispatch-building-a-lightning-fast-delivery-system-hpks8kgcc) · ByteByteGo · 21 upvotes · 0 comments

---

Tags: [#r](https://daily.dev/tags/r)

[View this post on daily.dev](https://daily.dev/posts/when-will-that-elevator-arrive-elevator-dispatching-yk1fmmihm)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"When will that elevator arrive? Elevator dispatching","url":"https://daily.dev/posts/when-will-that-elevator-arrive-elevator-dispatching-yk1fmmihm","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/when-will-that-elevator-arrive-elevator-dispatching-yk1fmmihm"},"datePublished":"2026-11-28T03:37:28.884Z","dateModified":"2026-11-28T03:37:50.684Z","description":"Picking the closest elevator by floor count can send you the wrong one, because it ignores direction. The post simulates a 23-floor building with 6 elevators...","image":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","thumbnailUrl":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","isAccessibleForFree":true,"articleSection":"R-bloggers","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"R-bloggers","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/98bcbbdf72774292a55ceda8f2277f1e","url":"https://daily.dev/sources/rbloggers"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/when-will-that-elevator-arrive-elevator-dispatching-yk1fmmihm","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"r","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"R-bloggers","item":"https://daily.dev/sources/rbloggers"},{"@type":"ListItem","position":3,"name":"When will that elevator arrive? Elevator dispatching"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/when-will-that-elevator-arrive-elevator-dispatching-yk1fmmihm#faq","mainEntity":[{"@type":"Question","name":"Why is assigning the nearest elevator by floor distance a poor dispatching algorithm?","acceptedAnswer":{"@type":"Answer","text":"A nearest-elevator rule ignores direction, so an elevator one floor away but moving the wrong way may take longer than one farther off already heading toward you. In a 23-floor, 6-elevator simulation, an ETA approach that adds a 2-second turnaround penalty picked an elevator on floor 14 reaching floor 11 in 3 seconds instead. Developers exploring algorithm trade-offs like this follow simulation and scheduling ideas on daily.dev."}},{"@type":"Question","name":"How do I estimate an elevator's arrival time in R when accounting for direction and turnaround?","acceptedAnswer":{"@type":"Answer","text":"Compute time per elevator from its floor, direction and destination at one floor per second. A stationary elevator takes the floor distance. An up-moving elevator for a down request must finish its trip, reverse and return, adding a 2-second turnaround penalty. A down-moving elevator above the passenger takes the straight floor difference. Assign each passenger to the minimum estimated time. daily.dev keeps R and algorithm-simulation techniques like this within reach as you learn."}}]}
```

