We’d like to take the opportunity to say thank you to everyone who joined us in taking on our Code Kata Challenge. It was great to see so many people participate! But now on to the reason you all are here…
The award for 1st place of our Code Kata Challenge:
- Implement a queue class using 2 stacks internally
- The queue class should implement an insert and retrieve method
- The 2 internal stacks should implement push and pop methods
Is Spencer! Spencer, as our 1st place winner, will be the final recipient of Are You Smart Enough to Work at Google?!
There were several reason’s Spencer was selected as #1.
- Deque class – Most submissions used the Java Stack class. Per the JavaDoc the Deque class is now preferred.
- Java implementation, Groovy tests – Includes the use of the Spock testing framework.
- Gradle – Post uses the open-source build automation tool Gradle
- Github – Style points as a GitHub submission
- EvilStackBasedQueue – The most important is the “evil” found in the EvilStackBasedQueue class. The class has two internal stacks but only uses one of them; recursion provides the evil ingredient that allows the class to work correctly. Recursion itself can be thought of as using a stack, since recursive function calls push function metadata onto the stack portion of the program’s memory address space.
While the implementation is less efficient than the 2nd and 3rd place entries, Spencer does indicate in his documentation that he would have produced a more efficient solution, if he were not making the “evil” implementation.
When doing code katas, sometimes after implementing a solution in the normal or obvious way, a constraint can be imposed upon the problem in which the usual implementation method is not allowed, or somehow restricted. This winner is an implementation that uses a constraint we didn’t ask for, but could have, assuming that we’d have been able to come up with it ourselves at all!
“Implement a queue using one and only one internal stack!”
Congrats Spencer for a great submission!
Don’t forget Code Kata Night is tomorrow from 3-5pm! If you have not already received an invite from us you should click the link below by the end of the day today!