E27: Three problems every software engineer should be able to solve

Santiago Valdarrama wrote a blog post entitled five problems every software engineer should be able to solve in less than an hour. Stop for a second and check it out!

If these five problems really take an hour to solve, that’s much too long for a WOD, so let’s just try to solve the first three. More important, we’ll use this as an opportunity to practice using GitHub, git, IntelliJ IDEA, Javascript, and Underscore.

The WOD

For this practice WOD, solve the first three of the five problems that Santiago Valdarrama thinks should take less than an hour. Actually, I will modify a couple of the problems so that you can hone your Underscore skills.

Ready? Let’s begin:

  1. Start your timer.

  2. Create an empty GitHub repo called “threeproblems” and clone it to your local computer.

  3. Create an IntelliJ “Static Web” project called “threeproblems” within your local threeproblems repo directory.

  4. Create two files: index.html and threeproblems.js. The index.html should load threeproblems.js as well as the Underscore package (available at <script src="//philipmjohnson.github.io/ics314f15/morea/underscore/underscore-min.js"></script>). You will code your solutions to the following problems in your threeproblems.js file.

  5. Problem 1: Write four functions that return the sum of the numbers in a given list using a for-loop, a while-loop, recursion, and underscore. Call them sumFor, sumWhile, sumRecursion, and sumTheSimpleWay.

  6. Problem 2: Write a function called zipList that accepts two lists of equal length and returns the result of 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]. zipList should not use underscore. Now write a function called zipListTheSimpleWay that does the same thing using underscore.

  7. Problem 3: Write a function called fib that returns a 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.

  8. Commit your finished program to GitHub.

  9. Check that your code is on GitHub.

  10. Stop your timer and record your time. Be sure to record it, because you will need your WOD time data when you write your technical essay.

Rx: < 24 min Av: 24-30 min Sd: 30-35 min DNF: 35+ min

Demonstration

Once you’ve finished trying the WOD for the first time, watch me do it:

Standard WOD Caveats

You’ll learn significantly less from watching me solve the WOD if you haven’t attempted the WOD yourself first.

While it’s an achievement to finish the WOD no matter how long it takes, you might experience “diminishing returns” if you work longer than the DNF time. Thus, it is usually strategic to stop working at the DNF time and watch my solution.

After watching my solution, I recommend that you repeat the WOD if you have not achieved at least Av performance. If so, be sure to:

Feel free to keep trying until you make Rx if that’s of interest to you.

Submission Instructions

To be completed by the time and date indicated on the Schedule page.