Level 2.1 — Elevator Maintenance
- My Google FooBar Journey: Level 1 — Getting the Invitation.
- My Google FooBar Journey: Level 2.1 — Elevator Maintenance. (This one)
You survived a week in Commander Lambda’s organization, and you even managed to get yourself promoted. Hooray! Henchmen still don’t have the kind of security access you’ll need to take down Commander Lambda, though, so you’d better keep working. Chop chop!
So now I had Level 2 access, but defeating Commander Lambda was still a long ways off. The next obstacle in my quest to free my bunny brethren, my next immediate key to progression, was a rather fun challenge.
At a cursory level, this is quite a simple one really; the devil is hidden in the edge cases. I initially started with a really unclean solution to force myself through, and for the most part it worked. However, I simply couldn’t crack open some of the test cases, no matter how many more hacks I introduced.
So I took a deep breath and a got good night’s sleep. Next morning, I got up, drank some coffee, and refactored the code. It passed all test cases in one shot.
A small tangent on good code
Before I get to the code, here is something I want to stress, always try to write clean code. I know it’s not really necessary in a competitive coding environment, in-fact sometimes it becomes detrimental to the cause. In future levels, I have taken many shortcuts that I would never write in a production environment, and would never let any one whose code I am reviewing write. They made my life easier, and the code ran faster, and so I went with it, and you should too in your fooBar journey, but here is the important point, you should feel guilty about doing that.
If you can write working but unclean code without fear of the great man above, then you maybe a great coder, but you will be a terrible developer.
If you disagree with this, I’d strongly suggest you to read a post I wrote a while back, and even after reading that if you disagree feel free to drop me a note/comment and we can discuss this further.
Now back to the problem at hand
You’ve been assigned the onerous task of elevator maintenance — ugh! It wouldn’t be so bad, except that all the elevator documentation has been lying in a disorganized pile at the bottom of a filing cabinet for years, and you don’t even know what elevator version numbers you’ll be working on.
Elevator versions are…
Continue reading: https://towardsdatascience.com/my-google-foobar-journey-a6488df029cf?source=rss—-7f60cf5620c9—4