CS61C Fall 2014 Lab 1 - Number Representation

Goals

Reading

Policies and Partners

Please look over the lab policies in the first set of lecture slides to make sure you know what is expected of you.

We are REQUIRING that you have a partner for lab checkoffs. This will reduce the number of check-offs we have to perform as well as give you someone to discuss class material with. BOTH partners will need to be present at check-off to receive credit and both partners will be asked to participate during the check-off. Try your best to find someone in your lab section with similar work habits as yourself.

How Checkoffs Work

You'll notice that at the end of (almost) every exercise, there is a section labelled "Check-off." The items in this section are what you must successfully demonstrate to your TA in order to receive credit for completing the lab. Once you and your partner finish ALL of the exercises, you should put your names AND logins on the checkoff list on the board, and a TA or Lab Assistant will come and check you off.

Extra Credit Opportunity, beginning with the next lab: If you complete a lab before your assigned lab time and get it checked off in the first hour of your regular lab, you will receive one extra credit point on the lab (a 5 out of 4). This policy will begin with Lab 2 (next week's lab).

The CS61C Lab Machines

In CS61C, we will use the hive machines (the towers in 330 Soda) for all grading purposes. Whenever you're working from home, you should ssh into one of the 28 hive machines (hive1.cs.berkeley.edu to hive28.cs.berkeley.edu) in order to do your work. Unless we specifically instruct you to do so, don't ssh into any other instructional machine to do 61C work.

Although not required, we also highly recommend that you learn to use a text editor that works well over ssh. Going forward, this will save you a considerable amount of time setting up your environment in almost every EECS class. The instructional machines (in our case the hive machines) have everything you need for this class pre-installed.

Mini-Discussion

The first part of lab will be a mini-discussion given by your TA. Topics to be covered include:

Exercises

Exercise 0: Account Setup

Both you and your partner should do the following to ensure that your course account has been setup correctly:

  1. Log into your account using the details on the form. You should be prompted to enter some personal information (name, SID) so that we can accurately assign grades at the end of the semester.
  2. If you were not prompted to enter your information in the last step, run register in Terminal.
  3. Finally, you should change your password. In Terminal, enter ssh update.cs.berkeley.edu and follow the prompts.
  4. Now you're ready to start the lab!

Checkoff:

Run check-register and show the results to your TA.

Exercise 1: Binary Alphabet

Let's take 4-bit numbers. If we stack five 4-bit numbers on top of each other in binary, we can make patterns and pictures! To help visualize this, you can think of 0's and 1's as white and black instead. For example, what does the following bit pattern look like?

0 1 1 0   ■ ■ □
1 0 0 1   □ □ ■
1 1 1 1 -->   ■ ■ ■
1 0 0 1   □ □ ■
1 0 0 1   □ □ ■

Checkoff:

Exercise 2: Cisco Binary Game

Click here to find the game. The object is to match the number on the right with the unsigned binary representation on the left. This requires a combination of clicking and typing. And then there's time pressure to make things more fun!

The game gets progressively faster and more difficult are you progress. See if you can score over 20,000 points and get to Level 5!

Checkoff:

Exercise 3: 1,000 $1 Bills

I hand you a thousand $1 bills and ten envelopes. Your job is to find a way to put various numbers of dollar bills in those ten envelopes so that no matter what amount of money I ask you for (between $1-1000), you can simply hand me some combination of envelopes and always be assured of giving me the correct amount of cash.

Checkoff:

Exercise 4: Pearls Before Swine

This is one version of a very cool game that has a neat solution based on number representation.
Play the game here. First play a few times and see if you can win a few rounds.

After you've tried a few times, give the following Wikipedia article a glance (note that this is the misère version).
With this newfound knowledge in hand, you should be able to beat Juan every time! But it will likely still take some practice. Keep going until you can win consistently!

Checkoff: