jus341

Untitled

Jul 15th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. Problem Description
  2.  
  3. Baseball scoring program
  4.  
  5. Fans of baseball games often keep track of a games progress using scorecards and a set of symbols to represent different plays of a game. For example: a strikeout is traditionally represented by the letter K, and a walked batter is denoted by BB for "Base on Balls". Base Runners score a point if they reach Home (Fourth Base, if you will) before being tagged or forced out.
  6.  
  7. You are to write a program which accepts a stream of baseball plays and produces the final score of the game for Team Def (first at bat) and Team Con (second at bat). The set of symbols should produce unambiguous results. In order to avoid ambiguity with regards to Runners' movements, we will restrict the movement of Runners to make them more predictable. See each symbol below for restrictions on Runner movements.
  8.  
  9. If you need a refresher on the basic rules of baseball: http://simple.wikipedia.org/wiki/Baseball
  10.  
  11. Symbol Table
  12.  
  13. Sometimes a symbol table references a position through the use of a number (#). The position to number mapping is as follows:
  14.  
  15. 1 - Pitcher
  16. 2 - Catcher
  17. 3 - First Base
  18. 4 - Second Base
  19. 5 - Third Base
  20. 6 - Short Stop
  21. 7 - Left Field
  22. 8 - Center Field
  23. 9 - Right Field
  24. Assume that the Fielder for each position does not relocate to another positions. So if the ball is thrown to the Second Basemen, you may assume that he is standing on Second Base.
  25.  
  26. The symbols that will appear in the stream are as follows:
  27.  
  28. K - Strikeout
  29. BB - Base on Balls. Batter advances to first, Runners advance one base
  30. only if necessary.
  31. HR - Home Run. All Runners score.
  32.  
  33. B1 - Single. Runners advance one base.
  34. B2 - Double. Runners advance two bases.
  35. B3 - Triple. Runners advance three bases.
  36. Each of the preceding 3 symbols may be followed by one of the following two symbols, denoting how the Fielding team responded to the batters hit. Assume that base runners who are not forced out on their way to their "first" base (sequentially ahead, that is) then they successfully progress the correct number of bases. For example, if the Batter hits a triple with Runners on First and Second base, and a Fly Ball is caught then thrown to First, the Batter is Out, the Runner who was originally on First is Out, and the Runner who was originally on Second progresses three bases to Score. This rule may lead to some silly situations but it's MY problem and I'll make Baseball as silly as I want it to be.
  37.  
  38. F#+ - Fly ball caught by Fielder then potentially thrown for more outs.
  39. Assume that if a base is listed and a Runner could be thrown out by
  40. the ball then the Runner is thrown out. So if a Runner _was_ on
  41. first base and the throw chain includes first base, the Runner on
  42. first base is a terrible Runner and has been thrown out before he
  43. could get back to his base
  44. L#+ - Ground ball thrown through Fielder chain. Assume that if a base is
  45. listed and a Runner could be forced out by that Fielder then the
  46. Runner is forced out. So if a Runner _was_ on first base and the
  47. throw chain includes second base, then the Runner who was on first
  48. base is now thrown out. Note that in order for a Runner to be forced
  49. out all bases behind the forced Runner must be occupied (or about to
  50. be so). Our fieldsmen haven't yet learned how to tag a Runner out.
  51.  
  52. SB# - Stolen base. # is the position that the Runner was originally on.
  53. Runner advances to next position. Runners will never steal a base
  54. that is occupied.
  55. CS# - Caught Stealing. Runner who occupied position # tried to steal a base
  56. and failed.
  57. HBP - Batter hit by pitch.
  58. Sample Input / Output
  59.  
  60. Input:
  61.  
  62. KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKHRK
  63. Output:
  64.  
  65. Def - 0
  66. Con - 1
  67. Home
Advertisement
Add Comment
Please, Sign In to add comment