CSC 421: Algorithm Design and Analysis
Spring 2013

HW1: Hoop Stats


A sports reporter for the Creightonian has come up with a clever system for covering basketball games. Everytime a shot is taken in the game, he jots down two numbers on a piece of paper: the player's number (an integer between 1 and 99) and the type of shot taken (1 for free throw, 2 for 2-pointer, 3 for 3-pointer). A positive player number signifies that the player is on the Home team, while a negative player number signifies that the player is on the Visiting team. Likewise, a positive shot number signifies a made shot, while a negative shot number signifies a missed shot. For example, '3 -2' would signify that player #3 on the Home team missed a 2-point shot. Since it doesn't take long to jot down two numbers per shot, he can follow the action of the game and still keep an accurate record of all scoring. Once the game is over, he can then process his notes to report the final score and the statistics for each player. You are to write a program that does this post-game analysis for him.

Program Input

Your program should read in the game log from a file whose name is entered by the user. The first two lines of the file contain the names of the Home and Visiting teams, respectively. After that, each line will contain a pair of numbers, separated by whitespace, that represents a shot using the reporter's system. For example:

Creighton UNI 3 3 -24 -2 99 -2 -32 1 -32 -1 3 2 3 1 -24 2 1 2 -12 1 -12 1 3 -3

Program Output

Your program should produce a report that incudes the final score of the game (with the winning team's score listed first) and the high scorers for each team (including shooting percentages, rounded to the nearest integer). If there is more than one high scorer for a team, all should be listed and they should be ordered by player number. For example, the extremely low-scoring game described in the above log would yield the following report:

FINAL SCORE Creighton 8 UNI 5 HIGH SCORER(S) FOR Creighton #3 (6 PTS) (67% FG) (50% 3FG) (100% FT) HIGH SCORER(S) FOR UNI #12 (2 PTS) (0% FG) (0% 3FG) (100% FT) #24 (2 PTS) (50% FG) (0% 3FG) (0% FT)

NOTE: the output of your program must follow the format shown here exactly (including capitalization, use of parentheses, and spacing).