Homework 11

This homework is worth 15 points.

Goals

When you finish this homework you should:

Assignment

Write a program to perform each of the following tasks in either bash or python. You must write at least one solution in each language (ie I need 1 bash and two python, or 2 bash and 1 python scripts from you)

Please note, this is intended to be a group activity. You are encouraged to complete this during class working as a group. Multiple submissions of the same code are acceptable as long as the cooperation is noted in the comments of the programs. If you wish to form a small group to work on this code, or even work on it as an individual, that is also acceptable.

  1. Implement a program which uses the Sieve of Eratosthenes. Your program should take a single command line argument, the highest number (n) in the range to be searched, and output the primes between 2 and n.
  2. Write a program which takes a command, the arguments to that command and an output file and prints "good" if the output of the command with the arguments and the contents of the file are the same. If the results are not the same, the program should print "bad".
  3. Write a script to assist a professor in grading a set of programs. The professor keeps each student's work in a directory and all student directories are collected in a single directory. The students have all named their assignments the same thing (sieve.py for example) and the professor would like to automatically determine if each student's work produces the correct output for a given input. The professor has a file called testcases which contains a number of lines, each representing a trial run. The line consists of a command line argument to run the program, along with a file containing the correct output for that command. Your task is to produce a report indicating if each student produced the correct output for each test case.

    Assume that the directory contains sub directories billy, steve and sue. Within each of these directories is the program sieve.py and that each of these files is executable by user. The file testcases contains:

     
    sieve.py  20 ../data/case1
    sieve.py  50 ../data/case2
    sieve.py  100 ../data/case3
       
    Further assume that billy fails on all cases, steve works on the first two, but not the last and sue works on all three. Your program should output
    running sieve.py 20 ../data/case1
    billy  bad
    steve good
    sue   good
    sieve.py  50 ../data/case2
    billy  bad
    steve good
    sue   good
    sieve.py  100 ../data/case3
    billy  bad
    steve bad
    sue   good
    
    This tar file might be helpful.

Submission

Submit a tar file containing your scripts to your instructor.