7th Homework

This homework can be prepared individually or in teams of up to two students. It is up to you to find a partner in case you prefer teamwork. Download hw_7.tar.gz and extract it. Then add your homework solutions to the directory. Rename the directory according to the rules in the syllabus before submitting it as compressed archive. Don't forget to add the correct subject to the email when submitting.

Properly document the files you hand in to receive full credit. Each module (file), class and function needs a docstring. The purpose of each function needs to be summarized as a single sentence and then, if required, your intent and the behavior of the function can be described in more detail.

All of the tasks below need to

in order to receive (full) points. The grader will only award a part of the total points. The rest will be awarded if all your functions etc. have a comprehensive amount of proper unit tests.

  1. Austrian Social Security Numbers (1.5 points)
    Your company requires a tool to validate Austrian social security numbers (SSNs). As you wanted to save the company some money while minimizing your own effort, you tried to find an existing solution. Unfortunately, you couldn't find anything that really met your companies needs. However, from one of your friends in Sweden you obtained a part of a small GUI program (validate_ssn_gui.py) to validate Swedish SSNs. Using this Python module allows you to reuse the GUI and only implement the logic to validate an Austrian social insurance number. Such a number consists of 10 digits of which the 4th denotes a checksum allowing simple validation. The format of such a number is "xxxCddmmyy" where "xxx" are consecutively assigned digits, "C" is the checksum digit, "dd" donates the day, "mm" the month and "yy" the year of birth. The following formula for calculating the checksum uses the this notation: "x1" is the first of the three "x" digits, "m2" is the second month digit, and so on.
    C =(x1*3 + x2*7 + x3*9 + d1*5 + d2*8 + m1*4 + m2*2 + y1*1 + y2*6) modulo 11
    
    The required validation module (validate_ssn.py) should contain at least one function is_valid(digit_list) that returns True if the given list of digits represents a valid SSN. Otherwise, the function must return False. Note that your code should not make any assumptions about the correctness of the given input.
    Name the module: validate_ssn.py
  2. Flow Shop Scheduling (2.5 points)
    Your boss used a little tool to calculate the scheduling for your company's machines. As the IT department failed to realize a proper strategy for backing up important data, parts of the program got lost. Apparently the UI is still working, but when she wants to solve a particular problem the program crashes with a weird error she doesn't understand. Please run johnson_gui.py to understand what's going on and make the program work again by implementing the missing file.
    Your boss tried to collect all useful information for you. She found some old tests for the missing file (the grader for hw7). She also said she recalled that when she initially got the program, the techies had to install some Python libraries to make the GUI work. Furthermore, she found a part of the documentation of the lost file:
    """Return a flow shop schedule using Johnson's rule.
    
    Args:
        jobs: A dictionary of jobs. Job IDs are keys, a list of machine times
            are the values.
            E.g. {'3': [5, 7]} means that job '3' needs 5 time units on the
            first machine and 7 time units on the second.
    
    Returns:
        A list of job IDs.
    """
    

    Name the module: johnson.py
  3. Tests (5 points)
    Write a comprehensive suite of unittest for the previous tasks using Python's unittest framework. Write enough tests to get comfortable that your code works as expected.