Five programming problems every Software Engineer should be able to solve in less than 1 hour

Whenever I post a job request for a Software Engineer position, applications start trickling in really quick. What bothers me is that several applicants will invariably have no idea of what "programming" means.

Of course, they think otherwise.

I guess is fine to apply for a "Front-End Web Developer" position if the only thing you know is jQuery, but since when "Software Engineer" means that only HTML, JavaScript, and CSS skills are required?

(And I love those who can't shut up about XML, JSON, XSLT, SOAP, HTTP, REST, SSL, and 200 more acronyms, but can't differentiate between the int and float data types.)

Can you actually code anything?

For my Software Engineer position I'm usually expecting you to be able to code something. I'm talking about real code here: I give you a problem, and you write a solution for it using any programming language you feel confortable with.

Do you think you can actually do this?

Here is the deal: if you can't solve the following 5 problems in less than 1 hour, you may want to revisit your resume. You might be great at doing whatever you do today, but you need to stop calling yourself a "Software Engineer" (or Programmer, or Computer Science specialist, or even maybe "Developer".) Stop lying to yourself, and take some time to re-focus your priorities.

The 5 problems

(The following problems are ridiculously simple, but you'd be surprise to discover how many people struggle with them. To the point of not getting anything done at all. Seriously.)

Problem 1

Write three functions that compute the sum of the numbers in a given list using a for-loop, a while-loop, and recursion.

Problem 2

Write a function that combines two lists by alternatingly taking elements. For example: given the two lists [a, b, c] and [1, 2, 3], the function should return [a, 1, b, 2, c, 3].

Problem 3

Write a function that computes the list of the first 100 Fibonacci numbers. By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is the sum of the previous two. As an example, here are the first 10 Fibonnaci numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, and 34.

Problem 4

Write a function that given a list of non negative integers, arranges them such that they form the largest possible number. For example, given [50, 2, 1, 9], the largest formed number is 95021.

Update: Apparently this problem got a lot of people talking (although not as much as Problem 5 below.) You can click here to read my solution.

Problem 5

Write a program that outputs all possibilities to put + or - or nothing between the numbers 1, 2, ..., 9 (in this order) such that the result is always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100.

Update: (Here is one solution to this problem in case you are curious.)

Unfortunately, you aren't the one that needs this

If you bother to read this blog at all (or any other blog about software development), you are probably good enough to solve these and 5 more problems within the hour. The people that think are above all these "nonsense" are usually the ones that can't code crap.

(And I'm sorry for the rant.)

If you know one of these characters, share this post with them. Challenge them to solve the problems. Help them if you care. Who knows, maybe they learn something from this.

Update: Posted answers for problems 4 and 5

Due to the overwhelming response to this post, I posted my solutions to Problem 4 and Problem 5 which were the most controversial problems in this post.

Update: More programming challenges

I love these type of programming problems. I'm going to try to publish one problem every weekend, hoping I'll have the time to find a good one and solve it myself. Here is the first one to celebrate Mother's Day: Programming challenge: rotating a matrix 90 degrees in place.

Please, get in touch with me and send me your favorite challenges.

Have something to say about this post? Get in touch!

Want to read more? Visit the archive.