Skip to main contentdfsdf

Home/ Joel Liu's Library/ Notes/ Interesting facts love it

Interesting facts love it

from Twitter

这是个有趣而又惊人的事实:人们在面对全新事物之时会变得格外悲观,即便他们通常很乐观。于此同时,同样的人,在觉得自己对某事已经熟悉之后,又会变得过分乐观。第一个事实往往会把一个聪明人变成笨蛋,不幸的是,后一个事实的作用也是如此。

Many of us ride elevators every day. We feel like we understand how they work, how they decide where to go. If you were asked to put it into words, you might say that an elevator goes wherever it's told, and in doing so goes as far in one direction as it can before turning around. Sounds simple, right? Can you put it into code?

In this challenge, you are asked to implement the business logic for a simplified elevator model in Python. We'll ignore a lot of what goes into a real world elevator, like physics, maintenance overrides, and optimizations for traffic patterns. All you are asked to do is to decide whether the elevator should go up, go down, or stop.
How does the challenge work? The simulator and test harness are laid out in this document, followed by several examples. All of this can be run in an actual Python interpreter using Python's built-in doctest functionality, which extracts the code in this document and runs it.
A naive implementation of the business logic is provided in the elevator.py file in this project. If you run doctest using the provided implementation, several examples fail to produce the expected output. Your challenge is to fix that implementation until all of the examples pass.
Open a pull request with your solution. Good luck! Have fun!

Would you like to comment?

Join Diigo for a free account, or sign in if you are already a member.

Joel Liu

Saved by Joel Liu

on May 28, 11