jli

Untitled

jli
Feb 27th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. Problem Statement
  2. The latest version of your favorite adventure game has just been released. On each level you search for stars that earn you points. Simply moving over a location containing stars allows you to acquire them. To help you on your journey, you are given an overhead map of the level in a String[]. Each character in level describes the number of stars at that location. You begin in the upper left spot of the map (character 0 of element 0 of level). On the current stage you must move according to the following rules:
  3. 1) On the first pass you may only move downward or rightward each move (not diagonally) until you reach the lower right corner.
  4. 2) The second pass begins in the lower right corner where the first pass ended, and proceeds back to the beginning using only upward and leftward steps (not diagonal).
  5. 3) The final pass, like the first pass, begins in the upper left corner and proceeds to the lower right corner using only rightward and downward (not diagonal) steps.
  6. Once the stars on a spot are claimed, they cannot be claimed again on a future pass. Return the largest possible number of stars that can be acquired.
  7.  
  8. Definition
  9.  
  10. Class: StarAdventure
  11. Method: mostStars
  12. Parameters: String[]
  13. Returns: int
  14. Method signature: int mostStars(String[] level)
  15. (be sure your method is public)
  16.  
  17.  
  18. Constraints
  19. - level will contain between 2 and 50 elements inclusive.
  20. - Each element of level will contain between 2 and 50 characters inclusive.
  21. - Each element of level will contain the same number of characters.
  22. - Each character in each element of level will be a digit ('0' - '9').
  23. - Character 0 in element 0 of level will be '0'.
  24.  
  25. Examples
  26. 0)
  27.  
  28. {"01",
  29. "11"}
  30. Returns: 3
  31. 1)
  32.  
  33. {"0999999999"
  34. ,"9999999999"
  35. ,"9999999999"
  36. ,"9999999999"
  37. ,"9999999999"
  38. ,"9999999999"
  39. ,"9999999999"
  40. ,"9999999999"
  41. ,"9999999999"
  42. ,"9999999999"}
  43. Returns: 450
  44. 2)
  45.  
  46. {"012"
  47. ,"012"
  48. ,"012"
  49. ,"012"
  50. ,"012"
  51. ,"012"
  52. ,"012"}
  53. Returns: 21
  54. 3)
  55.  
  56. {"0123456789",
  57. "1123456789",
  58. "2223456789",
  59. "3333456789",
  60. "4444456789",
  61. "5555556789",
  62. "6666666789",
  63. "7777777789",
  64. "8888888889",
  65. "9999999999"}
  66. Returns: 335
Advertisement
Add Comment
Please, Sign In to add comment