Most Programmers cant solve this (2)

This is the 2nd part of a previous blog post. I have included more programming puzzles which most “programmers” usually fail to solve in programming interviews.

They are sorted in order of increasing complexity.
1. Write a program that prints out in reverse order, every multiple of 3 between 1 and 100.
2. Reverse a string.
3. Reverse a sentence “Bob likes dogs” to become “Dogs likes Bob”. please note the capitalization of the words.
4. Find the minimum value in a list. (hint create your own list of items containing both words and integers)
5. Find the maximum value in the list created in (4).
6. Return distinct values from a list that includes duplicates (i.e. 1, 3, 5, 3, 7, 3, 1, 1, 5) -> (1, 3, 5, 7).
7. Return distinct values from the list in (6) including the number of times each distinct item appears in the list. “(1)3, (3)3, (5)2, (7)1.

P.S: Easter egg: If you are interviewing a horde of “programmers” and want to prune the number by at least 60% give them this puzzle to solve in longhand: “Swap the value of 2 variables”. You would be amazed at the result.

Advertisements

One thought on “Most Programmers cant solve this (2)

  1. Some of these are actually pretty easy to solve if you use the right language for the job.

    E.G. your easter egg quizz would need a temp var in Java but can be done without in Ruby, because this syntax is allowed:

    x,y = y,x

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s