CSC 421: Algorithm Design and Analysis
Spring 2017

HW1: Hoop Stats


A sports reporter for the Creightonian has come up with a clever system for covering basketball games. Every time a shot is taken in the game, he jots down two numbers on a piece of paper. The first number identifies the player. If the player is on the home team, his or her number (assumed to be between 0 and 99) is entered as is (e.g., 10). If the player is on the visiting team, the player's number plus 100 is entered (e.g., 110). The second number identifies the type of shot taken, with 1, 2, and 3 representing a made free throw, 2-pointer, and 3-pointer, respectively. Negative numbers (-1, -2, and -3) represent missed shots of those types. For example, '3 -2' would signify that player #3 on the home team missed a 2-point shot, while '155 1' would signify that player #55 on the visiting team made a free throw. 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 team and player statistics. 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. Each line in the file will contain a pair of numbers, separated by whitespace, which represents a shot using the reporter's system. For example:

3 3 124 -2 55 -2 132 1 132 -1 3 2 3 1 124 2 1 2 112 1 112 1 3 -3

Program Output

Your program should produce a report that incudes the team stats and stats for the high scorers for each team. 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:

HOME (8 PTS) (3/5 FG) (1/2 3FG) (1/1 FT) High scorer(s): #3 (6 PTS) (2/3 FG) (1/2 3FG) (1/1 FT) VISITOR (5 PTS) (1/2 FG) (0/0 3FG) (3/4 FT) High scorer(s): #12 (2 PTS) (0/0 FG) (0/0 3FG) (2/2 FT) #24 (2 PTS) (1/2 FG) (0/0 3FG) (0/0 FT)

NOTE: the output of your program must follow the format shown here exactly (including capitalization, use of parentheses, and spacing). Any lines in the file that contain illegal entries should be ignored.