79794497

Date: 2025-10-19 21:26:04
Score: 1
Natty:
Report link

You dont need to think about direction, instead of current floor of the elevator you should chose the destination floor.
The order shoud be unocupied > ocupied
if both unocupied choose current.closer
if both at the same floor choose elevator 1 (just a arbitrary because it wont matter)
if both occupied choose destination.closer
if elv1.destination = elv2.destination choose 1.

you could use a counter, once goes elv1, then elv2, then 1, then 2. so both elevators get used more evenly
this logic also lacks if 2 or more people press the button at the same time... anyway good luck

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Samuel Alexandrino de Oliveira