Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A fine opening, because not only is it the stupidest algorithm that could possibly work, but it also tees up the obvious follow-up questions: "How efficient is your method? How much time will it take in the worst case? How much in the best case? How much in the average case? Can you improve on this?"

These follow-up questions, and the fluency with which the candidate navigates them, are actually the point of the exercise. Well, that and to learn whether or not you're talking to someone who can't properly state any algorithm, and to help gauge your candidate's level of primadonnatude. [1]

[EDIT: Okay, I typed this up before people stated the version of the question with the 2-mouse-lifetime time limit. That version is, IMHO, an awesome puzzle but too damn hard for an interview question.]

---

[1] There is no one ideal level of primadonnatude. It depends on the business, the role, and the company culture. Steve Jobs is, arguably, the prima donna assoluta of computing, and that seems quite appropriate for his job. On the other hand, a good second grade teacher, the sort of person who enthusiastically spends every day for fifty years instructing students in the subtraction of single-digit numbers, probably has very little primadonnatude.



The thing I loved about the second solution is that it actually performs better at scale. I love the irony of the function with the higher growth rate being the better function as the number of wine bottles increases.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: