CSE 121e: Week 02

Ponder and Prove

Introduction

For this week's task, you will practice using basic Erlang syntax by modifying an existing project. The goal is to make sure all the unit tests pass. As you work on these, make sure to read through all the code in the team_builder.erl file. That is where all your code will go. You should also read through the unit tests in the bottom portion of that file and try to understand how they work.

Scenario: You work for a TV production company that is producing a game show. The Show is a program that has, as a major design component, competition between teams and cooperation within teams.

Your Task

Your boss needs help selecting good teams from persons that have been selected to be potential participants. He has assigned you to help with this effort.

  1. Being new to Erlang, you decide to start by doing some experimentation so you can see what to expect from Erlang lists and expressions. You have written some unit tests in the team_builder.erl file in the game_show.zip file you got from your team. You figured these would help you see what happens in various situations. Write code to complete the functions and tests in the team_builder.erl file. Download the project you created, unzip it, and finish the needed lines of code.

    You found a web page with a list of all of the possible assertions available.

Stretch Challenge (Optional)

Try experimenting with Erlang by putting the following in the REPL.

1234567890123456789.0 - 1234567890123456788.0.

Notice that the result is not 1.0.

Now put the following in the REPL.

1234567890123456789123456789.0 - 123456789012345678912356788.0.

Again, the result is not 1.0. See if you can figure out why this is so for both of these examples.

Suggestion: Take a look at Why are floating point numbers inaccurate?

Review

After completing the previous tasks:

  1. Review one of the many possible solutions for this task,
  2. Compare and contrast your code with the possible solutions’ code, and
  3. Make note of any improvements you could make for future tasks.
  4. Make note of what your approach does well.

Sample Solution Video Walkthrough