Skip to content

pierrebai's solution

Pierre B edited this page Oct 23, 2022 · 3 revisions

I wrote multiple solutions to the challenge. Mostly trying to get better results, although the final attempt turned out worse.

The best of the tree is elevators-no-requests which selects the closest floor which has buttons light-up whenever an elevator is idle. It opportunistically serves floors when passing by them and cancels queued requests and other elevators when doing these opportunistic services.

The code is trying to be clear about what it does by adding a large numbers of functions to the elevator objects and using long names for these functions. As always, clarity is done at the cost of program length. No attempt were made to try to fold down the functions into a mish-mash of apply/map/filter/etc.

On challenges 19, the perpetual challenge, it achieves an average of 12.2s with a maximum wait time of 40.1s.

Clone this wiki locally