Make-up homework 1 and 2

Due date: Monday, October 29 at noon

Late policy: no late make-up homeworks accepted.

Please read all the instructions carefully. Remember, everything is case-sensitive!

Getting Help and Academic Integrity

You should do all the work on your own without asking for any assistance from other people and without helping other students. In case you need help, you should:

  1. Take a look at the man pages, slides and suggested reading.
  2. If you have more than just a simple question, please consider coming to my office hours.
  3. Go to cornell.class.cs114 newsgroup and see if your question is already answered. If not, post it there. I will be happy to answer any questions posted to the newsgroup, not only HW-related ones.
  4. If you want to keep your question private, e-mail me at cs114@cs.cornell.edu. Please use newsgroup whenever possible. Questions posted to the newsgroup will be answered much sooner.

Everybody is welcome to do these make-up homeworks or parts of them. Nothing will be subtracted from your existing score if your answers are incorrect, so there is no risk involved (other than the risk of not getting some extra points).


Homework 1, Part I

Everybody is welcome to try doing this HW, but if you got at least 6 points for the original Part I, you will not receive any additional credit. If you had less than 6 points for the original part I, you can get up to 6-(original score) points on this one.

(1 point) Remove cs114-HW1 subdirectory from your home directory.

(1 point) Make sure that ~/cs114-HW1-mu/..../A directory exists and you are the only one who has any kind of access permissions for it.

(1 point) Go to HW1 subdirectory of the home directory of the user cs114. Somewhere inside of it there is file4. Copy file4 to your A directory.

(1 point) Make sure that you have only read access, group has only execute access and others have only write access to file4 (create an empty file4 if you haven't found the "real" one).

Now you are ready to have Part I graded. Run ~cs114/bin/grade-hw1-mu. If you run it several times, only the first grade will be counted, so do not run it until you are ready to turn in your homework. You should get a confirmation e-mail after your HW is received.


Homework 2

Everybody is welcome to try this make-up homework. Your new HW2 grade will be the sum of the original HW2 grade and the make-up HW2 grade, but not bigger than 17 points.

Setup

This is something you've probably already done for the "original" HW2, but if you modified file4 or file5, make sure you get a fresh copy.

(1) (0 points) Create a subdirectory cs114-HW2 in your home directory. Make sure you are the only one who has any kind of access permissions to it.

(2) (0 points) Go to ~cs114/HW2 directory. It has a subdirectory set up for each of the CS114 students. Copy all the files from ~cs114/HW2/your_netid to your cs114-HW2 directory. (In case you are wondering - these files contain lines semi-randomly picked from a bunch of man pages).

Emacs (3 points)

For this section, use Emacs. Some of these problems are quite tricky, so triple-check your results. You may find diff utility useful for checking what happened.

(3) (1 point) In file4, append space, ZZZ, and then another space right before the last symbol on all non-empty lines among the lines 30 through the end of the file. Example: if file4 contains a line
qwerty
you should change it into
qwert ZZZ y
Don't forget those spaces!
Hint: Look at the Emacs command replace-regexp (with M-x describe-function). It takes a regular expression and something to replace it with. It replaces all occurrences of the regular expression in the file, from the point where the cursor is. Read carefully how to use \N and \(...\). Experiment. How do you position the cursor to line 30? (Look at the mode line carefully.) How can you recognize the end of a line with a regular expression?

(4) (2 points) In file5, on all the lines that have at least two | symbols, replace the second | symbol with a & symbol.
Example:
ab | cd | ef |
should become
ab | cd & ef |
Hint: Again, how do you use \N and \(...\)? Experiment. Make sure you are replacing the second | symbol.

grep, egrep (4 points)

(5) (0 points) Using man command on babbage, read the grep man page and find out how to tell it to count the number of matches.

(6) (2 points) In file6, count the total number of all of the following:

Put this number onto the first line of ~/cs114-HW2/answer-mu file. Do not put anything else onto that line.
Warning: Look carefully at how [...] works. You may want to check the links on the web site, or check the man pages for regular expressions on babbage

(7) (2 points) In file7, count the number of lines that have an n somewhere before and somewhere after each a (this includes lines with no a's at all).
Put this number onto the second line of ~/cs114-HW2/answer-mu file. Do not put anything else onto that line.
Examples: The following lines should be counted:
nan
QWEnQWEaaaQWEnQWE
AAAAAAAAA
while the following lines should not be counted:
a
123annnnnnnnnnnnnn

Hint: All the correct answers for problems (6) and (7) are between 150 and 300. If your answer is not in that range, it must be wrong.

To submit make-up homework 2, run ~cs114/bin/grade-hw2-mu. As usual, only the first submission counts.


CS114 staff
Last modified: Wed Oct 10 18:40:13 EDT 2001