Goals
- Get your class account setup (in case you didn't last week).
- Build more intuition for working with binary.
- Get to know your classmates and play games!
Reading
- P&H (4th or 5th): 2.4
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:
- IEC prefixes
- Finishing leftover problems from discussion
- Bitwise Ops, especially Exclusive OR (XOR)
Exercises
Exercise 0: Account Setup
Both you and your partner should do the following to ensure that your course account has been setup correctly:
- 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.
- If you were not prompted to enter your information in the last step,
run
register
in Terminal. - Finally, you should change your password. In Terminal, enter
ssh update.cs.berkeley.edu
and follow the prompts. - 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:
- What five decimal digits produce the pattern above? What five hexadecimal digits?
- What letter is drawn with 1,1,9,9,6? 0xF8F88?
- What is the hexadecimal representation you would use to spell the letter 'B'? 'N' (you probably won't want to use 5 hex digits for this one)?
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:
- Score over 18,000 points and show your TA (pause the game or screenshot)!
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:
- Explain to your TA how to distribute the dollar bills in the ten envelopes.
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:
- Your TA will present to you a hypothetical Pearls Before Swine situation. Work out your next move for the TA.