The Five Card Trick Interview Question

Here’s one of my favorite magic tricks that can also be used as the source for a logic interview question. The trick requires two people working together, call them A and B. A regular deck of 52 cards is shuffled. One member of the “audience” selects any five cards from the deck and hands the five cards to person A. Then person A looks at the cards, picks one, and hands that card back to the audience. Person A rearranges the order of the remaining four cards and hands the four cards to person B. Person B is able to instantly name the mystery fifth card held by the audience. How does this trick work?

This is really a question about information encoding. Person A has to communicate the suit and rank of one of the five cards. A concrete example explains best. Suppose the five cards selected by the audience are 3c, 7d, 9s, Jc, Kh (three of clubs, seven of diamonds, nine of spades, jack of clubs, king of hearts). Because there are four suits, in any set of five cards there will be at least two with the same suit. So person A picks the 3c as the mystery card and removes it from the group of five, and gives it to the audience. To communicate “clubs”, person A places the Jc in the first position. That leaves the 7d, 9s, and Kh available to communicate the rank of the mystery card, which is 3. If the three cards are identified as low, medium, and high, then there are 3! = 6 ways to arrange them. In lexicographical order, LMH = 1, LHM, = 2, MLH = 3, MHL = 4, HLM = 5, HML = 6. So the 3c of clubs is five cards away from the Jc -> J-Q-K-A-2-3 which would be encoded as HLM, which would be Kh, 7d, 9s. In other words, person B sees Jc, Kh, 7d, 9s. Person B knows the mystery card is a club from the Jc. Person B sees HLM, which is the code for 5, adds 5 to the J and gets 3, so the mystery card is 3c.

This trick is an old one and is attributed to a mathematician named Fitch Cheney.

Add comment May 13th, 2012

The Triangle Interview Question

I was observing some Microsoft hiring interviews recently. The Microsoft interviewers were looking for people to work in the “Mobile Information Worker” group. Anyway, I asked one manager what he looks for in candidates and he answered quickly: “I look for five things and they are coding skill, coding skill, coding skill, intellectual smarts, and development and testing aptitude.” I wasn’t surprised because I’ve heard the slight variations on this same opinion stated many times. Later I heard an interviewer asking a candidate one of the classic interview questions. It runs something like, “Write a function that determines if three points in a plane form a triangle or not.” This is a pretty basic question. First you’d have to set the context for a Point object of some sort, and any associated methods, such as a Distance between two points. Next you’d have to determine the logical scenarios where three points do not form a triangle. For example, what if two of the points have the exact same coordinates? Anyway, I think one of the messages here is that if you want to enhance your career options in a software engineering environment, you’d be well advised to constantly upgrade your coding and algorithmic skills. These, after all, are what software engineering is mostly about.

Add comment May 6th, 2012

The Value of Practice Interviews

Recently, a relatively young person asked me for my opinion about a job interview situation. She saw a job opening that she thought she might be interested in. However she knew that the company had pretty much already decided to give the position to an existing employee within the company. Sadly, this is much more common than you might think. Many companies are required, for legal reasons, to post job openings and schedule interviews even when they already know who they want to hire. To complete the charade, these companies will actually schedule and conduct interviews where the candidate has no chance of getting the job. But regardless, this woman knew that if she applied for the job she’d get an interview, but would not get the job. I encouraged her to apply anyway and interview for the job. The idea is that interviewing is a stressful thing and the more practice you have, the better at interviewing you’ll become. The situation I described is a perfect opportunity for a practice interview. When you know an interview is real, but just practice, you’ll be much more relaxed and treat the interview as a conversation. After several practice interviews like this you’ll learn how to handle common questions, be confident, not appear desperate, and ultimately help find yourself a job position that is a good match for you and your employers. So, my advice is, never turn down a chance to interview for a job. Interviewing is a skill you can become better at only by practicing.

Add comment April 27th, 2012

What are the Top Technical Skills Hiring Managers Look For?

I deliver short talks to technical recruiters at software companies like Microsoft, Volt, Amazon, and Google. In these talks I describe technologies and products, and explain to the recruiters how to effectively recruit for software engineers. The technical recruiters are in constant communication with hundreds of hiring managers. So I often ask the recruiters what the hiring managers say they are looking for in terms of skills. By far the most important skill across all technical positions at technical software is coding, coding, coding. I hear this over and over, without any exceptions. And it makes sense — after all, software companies make software products and services. One of the problems for software engineers and recruiters these days is the unbelievable explosion of the number of programming languages and technologies. In the early 1990s it was quite possible for an engineer to have deep knowledge of most existing technologies — there just weren’t that many of them. This was essentially before the Web, so there was basically C/C++, rudimentary SQL, and maybe a scripting language like Perl. Now engineers and recruiters are faced with dozens of important technologies. A top-level engineer at Microsoft, Google, or Volt might have intermediate level knowledge of at least the following: C/C++ for systems work. HTML, CSS, and JavaScript for client-side Web programming. C# or VB.NET for both application development and server-side ASP.NET Web programming. SQL and ADO.NET for all kinds of purposes. One or more scripting languages such as Perl, VBScript, or PowerShell for utility programs. And this list is just the basics. Depending upon the particular job, a software engineer will need many additional skills. So, if you’re a software engineer, how can you keep up with this ever-growing list of things to know? The key is continuous education. The moment you stop learning new technologies in this field is the beginning of the end of your career options. Luckily the Web allows you to continuously upgrade your skill set, but you must make sure not to get too wrapped up in your day-to-day responsibilities that you stop learning new languages and technologies.

Add comment April 22nd, 2012

Listing Keywords on your Resume

A couple of days ago a technical recruiter called me and said he was having trouble finding someone who had experience witting plug-ins for the Visual Studio integrated development environment tool. I wasn’t surprised; most recruiting these days searches databases for keywords and “Visual Studio Plugin” isn’t something most people would put on their resumes. Anyway, I told my recruiter friend to search for things like “Visual Studios Development Tools Extensibility”, “Visual Studio DTE”, “VS add-in”, and on and on. This got me thinking. It might not be a bad idea for you to have different versions of your resume. The normal version would be intended for reading by a real human being, with sections Education, Experience, References, and so on. The online version of your resume could have an additional Keywords section that just lists dozens and dozens of variations of your technical skills (”JavaScript”, “JScript”, “Java Script”, etc.) as well as keywords that describe very specific, low-level, experience such as “Visual Studio Plugin”.

Add comment April 14th, 2012

Another Interesting LSAT Question

In a previous blog entry I mentioned that when one of my friends managers was preparing to take the LSAT exam and to apply to law school, I was surprised to see many combinatorial problems in the LSAT preparation books. Apparently lawyers need a sense of logic to compensate for a lack of a sense of ethics. Anyway, here’s an example similar to LSAT problems that I wouldn’t be surprised to see in a technical job interview at a company like Google or Microsoft.

During a period of 7 consecutive days (day #1 through day #7), exactly one of 7 software testers will test a Web site each day. The testers are Adams, Baker, Chung, Dunne, Elgen, Friel, and Green. But the order in which they test follows these 5 conditions.

1. Adams tests the site on either day #1 or day #5.
2. Friel tests the site on neither day #4 nor day #6.
3. If Dunne tests the site on day #1, then Chung tests on day #2.
4. If Elgen tests the site on day #4, then Friel tests on day #5.
5. Baker tests the site on the day after Chung tests.

Which of the following could be the order in which the software testers test the Web site?

a.) Chung, Baker, Adams, Green, Elgen, Friel, Dunne
b.) Chung, Baker, Friel, Adams, Green, Elgen, Dunne
c.) Friel, Baker, Chung, Green, Adams, Dunne, Elgen
d.) Friel, Dunne, Adams, Elgen, Chung, Baker, Green
e.) Friel, Dunne, Elgen, Green, Adams, Chung, Baker

In a problem like this, listing all potential combination would take too long: there are 7! = 7*6*5*4*3*2*1 = 5040 combinations. So you should use a process of elimination. For example, look at ordering a.) and then run down each of the five conditions. You immediately see that ordering a.) does not meet the requirements of rule #1 because Adams tests the site on day 3. I’ll leave it to you to figure out which rule is violated by answers b through d and therefore answer e is correct.

Add comment April 7th, 2012

Turning an Interview into a Conversation

Job interviews are stressful. One of the keys to a successful interview in many, but not all, cases is to take an active role in the interview and make it more of a conversation than a situation where the interviewer asks questions and you answer. For example, if the interviewer asks you, “What are your strengths?” and you answer to the best of your ability, you might then ask the interviewer, “Based on your experience, what characteristics do the successful people who work here have?” There are several advantages to being proactive. You show the interviewer you are someone who takes the initiative, and place yourself more as a semi-insider rather than someone who is just a candidate. Of course, like anything, you have to be careful not to overdo it. Yakking nonstop in an interview is an excellent way to get kicked out quickly. But by carefully moving an interview to a conversation, you can make a great impression and distinguish yourself from the other people who are interviewing for the position. The purpose of an interview in most situations is not to determine “if you’re good enough” — the purpose is really to see if you are a good fit for the position and the team. By steering an interview into a conversation you can help the interviewer and you determine this.

Add comment March 30th, 2012

The Blackjack Interview Question Part 1

A common question in a technical interview is something along the lines of, “sketch out an object oriented design to simulate the game of Blackjack.” This type of question will quickly reveal whether a candidate has OOP experience or not. Additionally, there are an amazing number of ways to tackle this problem which will give the interviewer insights into the candidate’s design abilities. The first question is how to represent a Card object. There are many approaches but most people define a rank (0-12 or 1-13 for Ace thru King) and a suit (0-3 or 1-4 for clubs thru diamonds). But with Blackjack, the value of Aces can be 1 or 11 so one design choice is to include an int array with two cells to hold the value(s) of the Card object. The alternative is to compute values as needed. Listed below is some C# code of how I might approach the question. With even such a simple problem the number of different approaches possible is astonishing. Notice I do not define get-set properties for the rank and suit. The idea is that they are set by the Card constructor and will never change. I define a pseudo-property GetValu() on the Card valu[] values so other code can get at them.

using System;

namespace BlackjackLib
{
public class Card
{
private int rank; // 0 = Ace, 1 = Deuce, 2 = Trey, 3 = Four, 4 = Five, 5 = Six, 6 = Seven, 7 = Eight, 8 = Nine, 9 = Ten, 10 = Jack, 11 = Queen, 12 = King
private int suit; // 0 = clubs, 1 = diamonds, 2 = hearts, 3 = spades
private int[] valu; // Ace = 1,11; Two = 2,2, Three = 3,3 etc.

// --------------------------------------------------------

public Card()
{
this.rank = 0; this.suit = 0; // Ace of clubs
this.valu = new int[] { 1, 11 };
}

public Card(int rank, int suit)
{
if (rank < 0 || rank > 12)
throw new Exception("Bad rank in Card(rank,suit)");
if (suit < 0 || suit > 3)
throw new Exception("Bad suit in Card(rank,suit)");

this.rank = rank; this.suit = suit;
this.valu = Valu(rank); // call helper
}

private static int[] Valu(int rank) // helper to assign card values
{
int[] valu = new int[2];
if (rank == 0) { valu[0] = 1; valu[1] = 11; } // Ace is 1 or 11
else if (rank == 9 || rank == 10 || rank == 11 || rank == 12) {
valu[0] = valu[1] = 10;
} // T,J,Q,K is 10
else { valu[0] = valu[1] = rank + 1; } // all non-Aces
return valu;
}

public Card(string c) // ex: "Ac" = ace of clubs
{
// implementation
}

public Card(int n) // 0 = Ac, 1 = 2c, 2 = 3C, . . . 51 = Ks
{
// implementation
}

public int Ordinal() // Ac -> 0, Tc -> 1, ..., Ks -> 51
{
// implementation
}

// --------------------------------------------------------

public int[] GetValu()
{
int[] result = new int[2];
result[0] = this.valu[0]; result[1] = this.valu[1];
return result;
}

// --------------------------------------------------------

public override string ToString()
{
return this.rank + "," + this.suit;
}

public string ToShortString() // ex: "Ac"
{
// implementation
}

public string ToLongString() // ex: "Ace of clubs"
{
// implementation
}

// ------------------------------------------------------------------

} // class Card
} // ns

Add comment March 23rd, 2012

An Interview Question from Socrata

Some time ago I saw an interesting newspaper article about a company called blist. It looks like they are now called socrata and they have an open interview question on their Web site at http://www.socrata.com that I think is interesting and typical of what you might see in an interview at many technology companies. Here is the question:

Without using any built in date or time functions, write a function or method that accepts two mandatory arguments. The first argument is a string of the format “[H]H:MM {AM|PM}” and the second argument is an integer. Assume the integer is the number of minutes to add to the string. The return value of the function should be a string of the same format as the first argument. For example AddMinutes(”9:13 AM”, 10) would return “9:23 AM”. The exercise isn’t meant to be too hard. We just want to see how you code. Feel free to do it procedurally or in an object oriented way, whichever you prefer. Use any language you want.

I don’t want to undermine Socrata’s Web site by putting an answer down in this blog entry, but I’ll make a couple of observations. After checking the input parameters for errors (null values, out of range values, etc.) I’d begin by converting the first time-as-string argument into a time-as-integer value based on a 24-hour clock (maybe by using a helper function). Next I’d add the second argument to that value, taking into account rolling over from one hour to the next (again, possibly using an auxiliary function). Finally I’d convert the result back to a time-as-string value (once again, perhaps using an auxiliary function). An entirely different, high-performance, alternative would be to code up the problem function as a look-up table. Notice that there are only 12*60*2 = 1,440 discrete legal inputs; I’ll leave it to you to figure out the rest of this approach.

One moral to this story is that when you go to a technical job interview at a technical company, be ready for technical questions. Sure, you will be asked things like, “Where do you want to be in five years?” and “What can you tell me about yourself?” but ultimately you must be able to produce. In a technical environment, that means you must be able to analyze and code.

Add comment March 17th, 2012

The Importance of Confidence in an Interview

When you are in a job interview at a company like Microsoft or Google, you absolutely must project a sense of confidence and a positive attitude to the person who is interviewing you. There are several related issues here. The field of software engineering is still very young, compared to say electrical engineering, and is changing with tremendous speed. Every few months significant, new technologies are released. Some recent examples that come to mind are Cloud Computing paradigms, the Web application MVC paradigm, and SQL geographical data types. This means that successful software engineers are constantly upgrading their skills. If you are an engineer who is successful at continuous learning you gain a sense of cautious confidence — an attitude that sends a message to a hiring manager that even though you know you don’t know everything, you have the ability to learn and upgrade your skills. In an interview, if you project a lack of a sense of confidence you are doomed. Hiring managers will interpret lack of confidence as a sure sign that a candidate is not a continuous learner. A sense of confidence and a positive attitude are almost, but not quite the same thing. By a positive attitude, I mean more of a cheerful nature with a sense of humor. Positive attitudes in people are usually correlated with a sense of confidence and raw, native intelligence. (Sociologists have done hundreds of such studies and the results are very clear: “good” personality traits are generally highly correlated with each other). OK, so just how do you practice having a sense of confidence and a positive attitude? The best way I know is to sit down and honestly list your strengths and weaknesses. In an interview, you are probably going to be asked what your strengths and weaknesses are anyway. Once you know your strengths, you’ll be confident about them, and have a positive attitude.

Add comment March 10th, 2012

Previous Posts


Volt Links

Conferences

Categories

Links

          

Feeds