Posts Tagged With Facebook

Facebook Puzzles

Blog

Hey, it’s been a while since I posted last.  After getting certified, I felt like I needed to push my programming skill further.  That’s where the Facebook Engineering Puzzles came into play.  I completed the first two training ones last August ("Hoppity Hop!" and "Meep meep!").  I also worked on the first easy puzzle, "Liar, Liar," but was unsuccessful in optimizing the solution to meet the requirements of the Puzzle Bot.  Finally, in March I had an epiphany and realized that I was going about the puzzle all wrong.  In less than a day I solved "Liar, Liar" in PHP with 3998.623ms as my longest test case.  After that, I solved "Date Battle" in 142.191ms and "Breathalyzer" in 19167.797ms. 

Finally, I spent an entire week working on "It’s a Small World" with no success.  I did everything I could. Without giving too much away, I created a balanced kd-tree and used a kNN search but it still ended up being WAY to slow.  I’ve optimized it into the ground, everything is running as fast as PHP can get away with.  Even after code profiling, I found all of my time is spent calculating SQRT (using BCMath) and I can’t figure a way to speed that up (stupid 20 decimal places).

So I’ve taken a break, hoping for that moment of enlightenment again.

5 Comments


  • Donate

    If my work has helped you and you want to return the favor, you could purchase something for me from my Amazon Wish List or send me a donation via PayPal.

  • License

    Unless otherwise noted, all source code and compiled files published on this website are released under the terms of the GNU Lesser General Public License.