Clarifications and Hints for Data Structures Problem

General Hints

  1. Read the problems carefully and study the Samply Input and Expected Output to infer what sort of inputs your program should be able to handle.

  2. The best way to satisfy the Auto Judge in PC2 is to use the TEST feature to run it on an input text file so that you can see if the output looks the same as the Expected Output for the same Sample Input lines. It should match up line-for-line, without extra blank lines that do not appear in the Expected Output.

  3. All spaces you see in Expected Output are simple spaces, so do not print tab-characters (\t) for your spacing.

  4. When you create a test input file, make the first lines or first cases be identical to those shown in the Sample Input followed by your own cases. The additional cases should include "boundary" conditions, like the smallest values or shortest strings allowable based on your reading of the problem. The Sample Input never includes all of these cases since you are expected to infer them from carefully reading the problem statement. If your program does not handle your additional cases correctly, there is a good chance that the Auto Judge will see that too.

  5. You can test your Python program on an input file the way PC2 does directly using DOS commands. The steps below pretend that your python program is called myProgram.py, your input data is myInput.txt, and both are in a folder on your H-drive named myDir. Adjust the following to match your own folder and filenames:
  6. The general form for most of your Python Programs in which the input is terminated by a blank line will look as follows (note: Ron showed a slightly different form in class with a done variable and an if statement inside of the while loop to avoid processing or break out when done is True):

    # Appropriate comments at the top and throughout for style points      
    ... import statements if needed ... 
    ... defined functions (or classes) if needed... 
    def main():
       ...
       line = raw_input().strip()
       ...
       caseNum = 0
       while (not done):
            caseNum += 1
            ...
            process the line 
            print whatever needs to be printed
            ...
            line = raw_input().strip()
            ...
    main()
    

    The general form for most of your Python Programs in which the number of cases is either given in the first line of input or can be computed from that will look as follows:

    # Appropriate comments at the top and throughout for style points      
    ... import statements if needed ... 
    ... defined functions (or classes) if needed... 
    def main():
       ...
       line = raw_input().strip()
       numberOfCases = ...from info in line...
       ...
       for caseNum in range(1,numberOfCases+1):
            input line(s) associated with this case
            strip, split, and convert as needed for processing
            process information for this case 
            print whatever needs to be printed for this case
    main()
    

  7. Note: You can resubmit solutions that the Auto Judge has already said YES to and PC2 will not penalize your score, even if later submissions prove to be incorrect. This is good if you want to clean things up for full credit and the "style" points Ron mentioned. We recommend that if you do this, please send us email so that we look at the correct Python program that you want us to grade (we will probably assume it is the last YES submission from you, but we might overlook that). --JJ