E27: Five problems every software engineer should be able to solve (Part 2)

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 second one. More important, we’ll use this as an opportunity to practice using GitHub, git, VSCode, Typescript, and ESLint.

The WOD

For this practice WOD, solve the following variation of the second of the five problems that Santiago Valdarrama thinks should take less than an hour.

Ready? Let’s begin:

  1. Start your timer.

  2. Create an empty GitHub repo called “ziplist” and clone it to your local computer. Don’t forget to check the box so that a README file is created.

  3. Open the local repo in VSCode.

  4. Set up your project to use our Typescript coding standards. Download five files into your project directory:

    Invoke npm install to install ESLint.

  5. Create two files: index.html and ziplist.ts. The index.html should load the ziplist.js file. Remember to compile your Typescript file to Javascript. Use npx tsc to compile your Typescript file.

  6. 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 use a loop. Now write a function called zipListTheFunctionalWay that does the same thing using Array functions. Add console.log statements for each function to show the result. For example, console.log(zipList(['a', 'b', 'c'], [1, 2, 3])); should output ['a', 1, 'b', 2, 'c', 3]. Check the output in the browser console.

  7. Make sure ESLint is running. For example, add newlines to the end of a file to see that an ESLint error is triggered.

  8. Make sure that there are no ESLint problems with your code. You can run npm run lint in the command line to check for ESLint errors.

  9. Commit your finished program to GitHub.

  10. Check that your code is on GitHub.

  11. 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: < 15 min Av: 15-20 min Sd: 20-25 min DNF: 25+ 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

By the time and date indicated in Laulima, submit this assignment via Laulima.

You must grant read access to this repo to the TA for your section. To do this:

Your submission should contain:

You will receive full credit for this practice WOD as long as you have attempted it at least once and submitted your work on Laulima with all required data before the due date. Your code does not have to run perfectly for you to receive full credit. However, if you do not repeat each practice WOD until you can finish it successfully in at least AV time, you are unlikely to do well on the in-class WOD. To reduce the stress associated with this course, I recommend that you repeat each practice WOD as many times as necessary to achieve at least AV before its due date.