My Interview Brain Teasers Part 1

As I mentioned in a previous blog post, I like to ask variations of brain teasers to data architect or other senior-level candidates.  Just google "interview brain teasers" and you'll see tons of examples that people use.  But there are good "brain teasers" and there are good "interview brain teasers".  The difficulty is making sure you have the latter and not just the former.  It's helpful to remember that candidates at an interview are nervous and in my opinion it isn't fair to ask "trick question" brain teasers.  

Greedy Pirates

I like to ask brain teasers in a manner where the interviewee doesn't even know that a brain teaser is being asked.  Instead, it is asked as if it was a business problem that I want the interviewee to solve for me.  For instance, a favorite brain teaser is the greedy pirates logic puzzle.  This is a good brain teaser but it's not entirely relevant to someone in IT.  Further, many people have heard of it and have memorized the answer.  You can usually spot these people quickly, they can answer the question without "showing their work" or the process they used to arrive at the result.  But by changing the scenario the pattern is less obvious to someone who does not understand the underlying principles of the problem.  Here is how I do it.

We have had a good year at our company and our manager has allocated $1756 to divide between the 17 members of our team.  He has told us that we can allocate the money however we choose but there must be at least a 50% majority voting for the plan.  In fairness, the most senior member of the team will submit his plan first.  If he does not get the requisite 50% vote he is eliminated from any bonus and the next most senior person submits his plan.  Assume we all are greedy and wish to maximize our bonuses.  Assume that the 17 members of the team were each hired in successive years.  Assume the most senior man (Employee 17) is also the smartest and his plan is voted for.  What is his plan?  Assume I the interviewer have 2 years at the company (Employee 2), what will my bonus be?  Will Employee 1 get a larger or smaller bonus than me and why?  

That's a much different scenario, is more relevant to a corporate environment, and is more fun frankly.  The trick is to see if the candidate can model the solution.  Here are some useful tidbits to help someone along.  

  1. Ask them to whiteboard everything.  Ask them to verbalize all of their thoughts and we can help them through the issues.  
  2. How many votes will be needed?
  3. Do you think the number of employees makes a difference?  
  4. Do you think the bonus amount makes any difference?
  5. What if there were only 1 employee?  How about 2?  Let's model it.  
  6. Now 3 employees?  Now 4?  The candidate should see the trend and be able to extrapolate the answers to the questions by now.  

By the end I like to see something like this on the whiteboard:

Assumptions:  Need 9 votes.  

ScenarioEmployee 1Employee 2Employee 3Employee 4Employee 5Employee 6Employee 7
1 Employee$1756      
2 Employees$17560     
3 Employees$175501    
4 Employees$1755010   
5 Employees$17540101  
6 Employees$175301010 
17 Employees$1748010101...

The pattern is even numbered employees get no money and odd numbered employees get a single dollar since they don't want to become an even numbered employee. Since I need 9 votes then I get $1756-8 = 1748.  Employee 1 does get more than Employee 2 since he is odd-numbered.  There are other possible solutions but this solution shows a clear pattern and engineers should always look for the patterns.  

[[My Interview Brain Teasers Part 2|I'll post more examples I use during interviews soon]].