Your version is shorter but it's not right! My code computes max_ride and max_wait across all people. Yours finds the max_ride and max_wait for each person and only keeps the last one.
As far as making the simulation more accurate, there are many ways I could go. For one thing I could limit the number of people in a single elevator. And I could have the elevators communicate so they don't all rush off to the same floor at once. But ultimately this would be counter-productive as a teaching example since it would only make the code longer and thicker.
Thanks,
-sam
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|