Live data from Hacker News

So You Think You Can Program an Elevator

github.com

111–118 of 118 posts

Re: So You Think You Can Program an Elevator

#111

Earlier quoted context omitted.

One thought comes to mind. What if the button light is not working? Hit the N button once, and you are on your way to floor N. But if the light is busted, you would hit the light again, and now you have deselected your destination. I think button presses should be indempotent for this reason alone.

This is why the standard practice of picking up the elevator phone and requesting a floor cancellation exists.

Seriously? Has anybody reading this ever done this? It seems to me that by the time the operator picks up and you tell them what you're trying to do and what elevator you are on it would be too late.

Re: So You Think You Can Program an Elevator

#112
post #87

Very similar immediately playable JavaScript version. http://play.elevatorsaga.com/ Which I'm now closing as I lost too much time to this the first time I saw it.

Somehow I find this API counter-intuitive and painful to use. - Why currentFloor() is a function not a property? - Why both goingUpIndicator() and goingDownIndicator() instead of .direction property? - Why name destinationDirection() instead of currentDirection? - Why only floor_button_pressed but no in-door button press event? I gave up.

1. Because maybe the author wanted to keep the property hidden and only expose a getter function and hide the setter? 2. Same reason. They are being set internally. A sane programmer would not give you the power to do that because its a product of internal calculations. 3. Naming of method/function and variables is the second hardest thing in programming :) 4. The callback of on.('floor_button_pressed') gives you an floorNumber argument which is more than sufficient. What event in real life would you describe with on('in-droor-button-press') ?

Re: So You Think You Can Program an Elevator

#113

This is both cool and disappointing. I'm sure this is more challenging than it looks, and it's cool to see emergent complexity from a (seemingly) simply set of conditions to satisfy. However, the reason I think about elevator programming isn't to make an elevator behave the way they do today. It's to make an elevator behave better than they do today. For example: * I don't want an elevator to close and reopen its doo…

Obviously you did not reach the level when you can program the behaviour of four elevators in the same time :) About the first and the 20th floor: How about if you've got 15 people on the 20th floor and one person on the 1st? Every button press is a request that could add more weight to the particular floor. After all the goal is to transport as many people as possible for a given time.

Re: So You Think You Can Program an Elevator

#114

Very similar immediately playable JavaScript version. http://play.elevatorsaga.com/ Which I'm now closing as I lost too much time to this the first time I saw it.

I stuck at challenge #10, can anybody help?

I am also stuck at number ten. There is a link "Wiki and solutions" in which I guess we could find some useful theory. Still haven't taken a look at it.

Re: So You Think You Can Program an Elevator

#115
post #30

This is both cool and disappointing. I'm sure this is more challenging than it looks, and it's cool to see emergent complexity from a (seemingly) simply set of conditions to satisfy. However, the reason I think about elevator programming isn't to make an elevator behave the way they do today. It's to make an elevator behave better than they do today. For example: * I don't want an elevator to close and reopen its doo…

THIS. However, the criterion you're optimizing for is still unclear. Should it be: a) the total number of steps the elevator takes b) the average number of steps each user has to wait c) the maximum number of steps each user has to wait d) the 90th percentile of user waiting steps Note: here, I'm counting the steps spent waiting for an elevator as well as the steps spent in the elevator till the destination as the sa…

I guess we are looking at a trade-off in every case. Is speed, waiting time, or moves(energy saving) your priority. When you order a set of six to eight elevators for a 70 story building you probably are allowed to set your preferences of how your elevators want to perform. This is why I could not get constant (100%) success rate with one universal algorithm. I always had to change something.

Re: So You Think You Can Program an Elevator

#116
post #75

Earlier quoted context omitted.

so are you saying that, similar to the elevator programming challenge itself, writing the elevator programming challenge was more difficult than it looked? cool. that probably put a bigger smile on my face than it should've, but still cool.

Yeah, but that can't be surprising. Software estimation is hard.

indeed it is. i think i'm especially bad at it, but a lot of people probably feel that way.

Re: So You Think You Can Program an Elevator

#117

Earlier quoted context omitted.

This is fantastic. Are there other good programming challenge / games like this? I'd love to see a collection of other similar games.

Robocode is another one: http://robocode.sourceforge.net/

I spent way too much time with Robocode a few years back. Those advanced "surfing" bots some people built though... It was quite disheartening having not the slightest bit of a chance as a novice programmer.

Re: So You Think You Can Program an Elevator

#118
HAWKHACK are Extraordinarily intelligent and smart Hacker,We are one of the rare gem of hackers who hack and build hacking software which most hackers can build on.We have an excellent record, recording 100% successes in all of our job.We are reliable and loyal to our clients and make the satisfaction and safety of our clients our priority.We render the following services at affordable price. UPGRADE UNIVERSITY GRADES HACK AND ADMIT YOU INTO ANY UNIVERSITY OF YOUR CHOICE HELP GET YOU A LEGIT AND ACCEPTABLE UNIVERSITY TRANSCRIPT TO APPLY FOR TRANSFER OR ADMISSION REMOVE CRIMINAL RECORDS HACKING SOFTWARES SOCIAL MEDIA HACK EMAIL ACCOUNTS PASSWORD HACK AND RECOVERY RETRIEVAL OF LOST FILE/DOCUMENTS BANK ACCOUNTS HACK BANK WIRE TRANSFERS TO ANY ACCOUNT OF YOUR CHOICE DATABASES HACK SALES OF VERIFIED CREDIT CARDS OF ALL KINDS UNTRACEABLE VPN CONTROL DEVICES REMOTELY HACK PHONE HACK AND SECRETLY READ TEXT MESSAGES AND WHATSAPP MESSAGE AND MONITOR CALLS VERIFIED PAYPAL ACCOUNTS HACK EMAIL INTERCEPTION HACK SKYPE HACK *CREDIT CARDS HACKER.NOTE NOTE...If you refer client to us as a result of the previous job done for you, you will stand a chance of getting any job of your choice hacked for you, free of charge. CONTACT US. WALTSTEPH82@GMAIL.COM + 1 601 866 5203
Post reply on HN