Watch These Movies if you Want to Work at Google

How Many Characters are in this Blog Post?

Brain HurtsDo you remember being taught math when you were young? If you were anything like me you hated word problems. That was the only time during math class that we could not just use mechanical processes. Instead, we had to think about how to apply those processes to real world problems.

The natural evolution of word problems in the adult world is Brain Teasers, those pesky puzzles that are supposed to be fun but, more often, are frustrating. For most people, the skill of solving riddles and impossible estimation problems has never had much use. That was until clever software companies, such as Microsoft and Google, famously began asking these types of questions during job interviews. The legends of these companies’ interview tactics are so predominant that they have essentially become their own category of technical interview questions.

How many golf balls can fit in a school bus?

Unprepared candidates confront brain teasers with shock and horror. A feeling of futility drapes over them like a giant rain cloud. Fortunately, all the candidate needs to understand is that he or she does not necessarily have to answer the puzzle correctly to “pass” the test.

 

The Interviewer’s Perspective

Brain Teasers are great because when they work, they are a simple way to lighten the tone of an interview. They are also great at unearthing important traits of the interview candidate:

  • How does the candidate handle pressure, such as a seemingly impossible problem?
  • How well can the candidate express his or her thoughts regarding a difficult solution?
  • Is the candidate capable of “thinking outside the box” or are all proposed solutions too straight-forward?
  • Specific types of puzzles test the candidate’s ability to estimate large unknown quantities.

“A hunter sets up camp, walks 10 miles south and 10 miles east. He shoots a bear and drags it 10 miles north back to his camp. What color is the bear?”

 

Wooden Puzzle

My Perspective

Through years of practice, I became comfortable with the word problems in math class. It was a required step in progressing in mathematics. Likewise, Brain Teasers become conquerable with practice.

Personally, I love Brain Teasers now. I enjoy when a friend sends me one I have not before heard. I find it worthwhile to stretch my mind by thinking about different types of problems.

Still, Brain Teasers are rather overused in interviews. As stated above, they can be useful when they work but, when they do not work, they often fluster an otherwise good candidate. Some puzzles require a certain basis of knowledge that can lend itself to bias. Consider the puzzle about the hunter above, the answer is “White.” Why? Because the only place on Earth that someone can walk X distance South, X distance East or West, X distance North and then arrive at the same point again is at the North Pole. Polar bears are the only type of bears that live there. Polar bears are white. The candidate may be able to logically reason through the problem, but sometimes a small piece of “common knowledge” becomes a roadblock.

Lastly, Brain Teasers take too much precious time during an interview to not uncover anything of import. They test the “A-Ha moment” of the candidate, a long period of silence followed by the sudden discovery of the answer in the candidate’s mind. In cases where the candidate solves the problem right away, it usually does not mean that the candidate is brilliant but that he or she has heard it before.

 

Tips for the Interviewee

As I mentioned, it is not required of the candidate to solve the problem. In most cases, the interviewer is trying to gain insight into how the candidate thinks and describes his or her thoughts. Therefore, the #1 suggestion for approaching these problems is to communicate your thoughts while you are reasoning through them. Talk aloud about alternative solutions you are considering. Ask questions of the interviewer about the constraints of the problem. If you cannot come up with a solution, explain some option that would get you close. Going back to the polar bear problem, it would probably be enough to understand that the hunter is at the North Pole.

For more tips and great job interview Brain Teaser examples, I recommend the book How to Ace the Brain Teaser Interview.

 

Brain Teasers in the Movies

Some of the most fun Brain Teasers to discuss with friends are those from movies. It’s interesting when someone has seen the movie and remembers the solution, but when you propose it again after some time, he or she does not remember it. Below are some examples of the best movie Brain Teasers (hopefully YouTube won’t remove them).

 

Metro (Retrieve a cap from a bottle)


 

Labyrinth (Which door to knock on?)

 

Die Hard with a Vengeance (How to get exactly 4 gallons of water)

 

Batman TV Series (Top 10 Riddler riddles)

 

Post your favorite Brain Teasers in the comments and good luck on your interview!

Advertisement

3 Silverlight Architecture Tips with Brad Himelstein

Recently, I dove back into XAML-based development to create some Silverlight plugins for a large web application. Most of my experience in XAML came from writing a WPF application from 2008 to 2009, so I had much to learn about the asynchronous data retrieval paradigm used in Silverlight. I had questions about UI Design Patterns, Service-Oriented Architecture (SOA), and how to reuse class libraries, so I asked Brad Himelstein, from CinCom, if I could pick his brain while we hit a few golf balls. Brad has continued working with Silverlight and WPF for a few years, since we worked together on the aforementioned WPF application.

Below is a summary of his tips as well as some quotes from our conversation.

 

Tip #1: Use Model View ViewModel (MVVM)

Me: “Do you ever use any sort of patterns for the UI?”

Brad: “MVVM

Me: “I am just now getting introduced to that. What are the benefits?”

Brad: “It is great, because you just setup the data context and do all your databinding, and it just magically works. Two-way binding works as well.”

 

Brad identified additional benefits during other parts of the conversation. MVVM’s primary purpose is to separate the concern of the behavior of an application from that of the user-interface design. It is a practical implementation that is cleaner to understand and easier to pass back and forth between designers and developers versus the default approach of placing logic in code-behind files. He provides sample MVVM source code here.

 

Tip #2 Extend Proxy Classes with Shared Custom Code

In my application, I use WCF RIA Services to query server objects and return them to the Silverlight client. This technique simplifies the process of retrieving service data and populating local objects because a local proxy object is created and populated automatically. In Brad’s words, “If the web service returns an object of class ‘Foo’, we don’t need to redefine ‘Foo’ in the Silverlight app.”

Unfortunately, I had a great deal of logic included with the retrieved classes that I also wanted to be able to use in the client. I asked Brad how to elegantly work around this limitation of Service-Oriented Architecture.

Me: “What I was hoping to get with RIA Services was, say I’ve got some class I’m returning from the service. I can load it with data easily but I have additional calculation properties on this class, such as FullName, which is just a property that returns FirstName and LastName concatenated. A local proxy object is created automatically for use in Silverlight, with data populated for FirstName and LastName, but the proxy does not retain calculation logic. Since I have a server-side object that has calculation properties defined, how can I share that code for use with the Silverlight client and the proxy object?”

Brad: “If you know you’re going to use FullName, then just create another string called FullName and set the property on the server so it is passed down to the client in the object, because it is not going to take those calculated properties and bring them down.”

Me: “But then that FullName would have a state when it returns.”

Brad: “Remember, you can extend everything. So on the client side, you can alternatively have your own Foo class, which can be used to extend the partial Foo class that is returned from the server.”

Brad’s suggestion was enough to help me come to a solution that fit my needs.

 

Partial Class Extensions

Let’s use the sample Class “User” to continue our example from above. In such a class, I can place fields of the User, such as FirstName and LastName in one file named User.cs. User class should be defined as a partial class, so we can combine definitions of the class from 2 separate files. Hence, in another file, named UserCalcs.cs, we should define calculated properties, such as FullName. At this point, the server behavior will work as it always would have if we had just implemented all properties and fields in the one file. However, the Silverlight client would not yet know about the FullName property.

 

Shared Files

An important limitation of Silverlight is that it can only reference projects that are compiled as Silverlight projects. In other words, Silverlight cannot natively reuse definitions from standard .NET class libraries. What it can do is recompile normal .cs files into a Silverlight assembly.

To do this, right-click on the Silverlight project in your Visual Studio solution and click Add Existing Item. Navigate to the file that contains the calculated properties, UserCalcs.cs. Click the file, and then click the down arrow next to the Add button. Choose Add As Link.

The Silverlight project will now compile this partial class definition. It will extend the proxy class as well as the server side class from the same file. Therefore, maintenance of those calculated properties can be shared between the client and the server side code from one file.

 

Tip #3 Learn HTML 5

Ok, Brad didn’t actually say this so bluntly, but it was a recurring theme of our discussion. Based on recent information about upcoming Windows (8) releases, Silverlight’s future is unclear. From what I have heard, Microsoft is committed to version 5 of Silverlight (current release is 4) but has made no guarantees beyond that. Windows 8 will have 2 versions of its Internet Explorer 10 browser: tablet and desktop. The tablet version will not allow plugins, like Flash and Silverlight. Some have summarized the decision by stating that from Microsoft’s standpoint, Silverlight is “no longer strategic.”

Still, the death of Silverlight development, especially in corporate environments, is distant. Here is a great Microsoft client decision workflow about the correct technology to leverage based on your needs. I believe it reinforces the idea that even after Windows 8 is released, new Silverlight applications will have their place.

Lastly, even though Windows 8 tablets will not allow Silverlight plugins to be loaded within its browsers, native Windows 8 tablet apps will be developed using WinRT. As Brad informs us, this gives us Silverlight developers hope, as WinRT is still “just C# and XAML.”

 

By