Sewickley Academy Programming Team
Programming Contest:  7-Feb-2002
David Kosbie (Faculty Advisor)
Sewickley Academy

Link to Programming Contests home page .

Team Questions (StBon-style)

The contest runs for 3 hours.

Read these problems very carefully.

Question 1:  Lap Larry.  Lucy and Larry are running around a track.  They started at the same time, at the same location, in the same direction.  But Lucy is faster than Larry, and so she will eventually lap him.  Your problem:  read in a whole number -- trackYards -- the perimeter of the track in yards, followed by two doubles -- lucySpeed and larrySpeed -- these being Lucy's speed in feet/second and Larry's speed in miles per hour.  Print out one whole number:  the time, in milliseconds and rounded to the nearest millisecond, it takes Lucy to lap Larry.  [ Note that there are 3 feet in a yard and 5280 feet in a mile. ]

Question 2:  Football Scores.  Here, you write a simple football score keeper.  In football, a touchdown (TD) is worth 6 points, a kicked extra point (KEP) is worth 1, any other extra point (EP) is worth 2, a safety (S) is worth 2, and a field goal (FG) is worth 3.  Also, a missed extra point (MEP) and missed field goal (MFG) are worth 0 points.  Your input will be a series of lines, each representing one score in the game, terminated by the end of file.  Each line either states what quarter it is (as in QUARTER 1, or GAME OVER), or contains, in order:  the scoring team's name (one word, only alphabetics), a comma, the score type, a comma, and a commentary on the score.  As in:
QUARTER 1
STEELERS,FG,Kris Brown hooked it left, but a gale blew it back (whew!)
QUARTER 2
BROWNS,TD,Despite the wideout falling down twice, he easily beat Chad Scott
BROWNS,KEP,Logan almost blocked it!
QUARTER 3
QUARTER 4
BROWNS,FG,Chad Scott beaten repeatedly to place Brownies in field goal range
STEELERS,TD,Zeroue runs 80 yards, runs out of gas, laterals to Bowers!
STEELERS,MEP,Kris Brown missed the ball entirely!
STEELERS,S,Jason Gildon and Kendrell Bell save the day!
GAME OVER

Your task:  Read in a game description, and output the final score, listing the winning team first, or in the case of a tie, listing the teams in alphabetical order.  In the game above, you should ouput:
STEELERS 11 - BROWNS 10

Question 3:  Bug Hug 1.   Bernie Bug and Betsie Bug are both sitting on a single sheet of graph paper (where 0,0 is the topleft, and all coordinates are non-negative, akin to screen coordinates).  And Bernie and Betsie need a hug.  So they crawl in a straight line towards each other until they meet and get that happy hug.  Your problem:  read in four doubles -- in order: bernieX, betsieX, bernieY, betsieY -- denoting Bernie and Betsie's locations on the grid -- followed by two more doubles -- in order: betsieSpeed, bernieSpeed -- denoting their respective speeds in gridUnits/second.  Print out three numbers:  the x,y location that they meet, and the total time in minutes until they meet.  All output must be rounded to two decimal places and must always include those two decimal places (so output 10 as 10.00, and output 10.005 as 10.01).

Question 4:  Shrunken Triangles.   No story here (sorry).  First, read in six floating point numbers -- x1, y1, x2, y2, x3, y3 -- representing the vertices of a triangle.  Now you repeatedly shrink the triangle by connecting its three midpoints and using that triangle.  Repeatedly shrink the given triangle until the area of the triangle is less than or equal to 1.  Output the number of times the triangle was shrunk, and the perimeter of the resulting triangle.

Question 5:  City Codes.  Here we assign three-letter city codes.  For example, we may assign "Dallas Fort Worth" the code DFW and Pittsburgh the code PIT.  Your task is to read in a list of up to 100 city names (which may only contain alphabetics or a single space between words in the name), one per line (no extra whitespace), terminated by a blank line.  Your output:  in the same order, the 3-letter city codes for these cities, listed 15 per line, all in uppercase, and separated by a space (no space at end of line, however).  To find the 3-letter code for the cities, apply the following rules to each city in the order input, and use the lowest-numbered rule which is applicable and which generates a unique name (ie, it cannot conflict with a name already given to a city in the list).
Rule 1:  If the city is just one word, use the first 3 letters of the word.
Rule 2:  If the city is three words, use the first letter of each word in order.
Rule 3:  If the city is two words, and the first word is one of "New", "North", "South", "East", or "West", use the first letter of the first word and the first two letters of the second word.
Rule 4:  If the city is two words, use the first two consonants of the first word and the first letter of the second word.
Rule 5:  Use the first available code, alphabetically, which does not contain any duplicate letters (ABC is the first such code, if it is not yet taken).

Question 6:  Bug Hug 2.   Bernie Bug and Betsie Bug need another hug.  This time, though, they each are sitting on their own piece of graph paper (sheet1 and sheet2 respectively), but those pieces of graph paper are themselves sitting on a third piece of graph paper (sheet3).  First, read in two doubles -- in order: sheet1left, sheet1top.  These represent the point on sheet3 where the topleft of sheet1 sits.  But sheet1 may not be rectilinear -- it may be at an angle.  So read in four integers a1,b1,c1,d1 (where a1+b1 != c1+d1), plus another double -- sheet1angle -- which represents the angle in degrees to the horizontal (where, as in standard trigonometry, 0 degrees points to the right and 90 degrees points up) on sheet3 for the vector drawn in sheet1 coordinates from (a1,b1) to (c1,d1).  Next, read in the same data in the same order for sheet2:  sheet2left, sheet2top, a2, b2, c2, d2, sheet2angle.  Now the problem is the same as before:  read in four doubles -- in order: bernieX, betsieX, bernieY, betsieY -- denoting Bernie and Betsie's locations on their respective grids (Bernie is on sheet1, Betsie is on sheet2) -- followed by two more doubles -- in order: betsieSpeed, bernieSpeed -- denoting their respective speeds in gridUnits/second.  Print out three numbers:  the x,y location that they meet (in sheet3 coordinates), and the total time in minutes until they meet.  All output must be rounded to two decimal places and must always include those two decimal places (so output 10 as 10.00, and output 10.005 as 10.01).

Question 7:  Scrabble Hint.  Here you write a simple Scrabble hint generator.  First, read in the point values for every letter.  These are input on a single line as a positive integer value, a colon, then every letter which has that value, then a comma, and another such value-colon-letters entry until all values are specified.  For example (not real Scrabble values, but valid input for this problem nonetheless):
1:ABCD,2:EFGHIZ,3:JKL,4:MNOPQRSTUVWXY

Note that there is always one additional tile type, the #, which is blank and so may match any letter, but which itself scores zero points.  Next you read in the dictionary, which is a series of words separated by whitespace, terminated by the sentinel "_end_" (which itself is not part of the data; it just delimits the end of the input).  For example
THIS IS A DICTIONARY ALBEIT NOT A VERY GOOD ONE _end_

Finally, read in a rack of 1 or more tiles, listed as consecutive characters terminated by whitespace, as in:
L#EA#QTZ

Your task:  print out the word in the dictionary which can be constructed with these tiles and which produces the highest score followed by the actual tiles used to construct the word and then followed by the score for the word.  Resolve ties to the word using the fewest blank tiles, and then to the alphabetically first (nearest to "A") word.  Here, the output would be:
ALBEIT AL#E#T 10