Advertisement
Nenogzar
Jun 18th, 2024
28
0
Never
This is comment for paste 02. Fishing Competition - 3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # ******* TASK CONDITION ******* #
  2.  
  3. You are a longtime captain of an old fishing vessel.
  4. The new fishing season begins and you prepare your ship to set sail in search of the big catch…
  5.  
  6. You will be given an integer n for the size of the fishing area with a square shape.
  7. On the next n lines, you will receive the rows of the fishing area.
  8. You will be placed in a random position, marked with the letter 'S'.
  9. There will be fishing passages on random positions, marked with a single digit.
  10.  
  11. There will be whirlpools marked with 'W'.
  12. All of the empty positions will be marked with '-'.
  13.  
  14. Each turn until the "collect the nets" command is received you will be given commands for your movement.
  15. Move commands will be: "up", "down", "left", and "right".
  16.  
  17. • If you move to a fish passage,
  18. you collect the amount equal to the digit there, the passage disappears and should be replaced by '-'.
  19. • If you fall into a whirlpool – the ship sinks and loses its catch, the program ends.
  20. • If you leave the fishing area (go out of the boundaries of the matrix)
  21. depending on the move command you will be moved to the opposite side of the one you were on.
  22. /Example: In a 3x3 matrix you are at position [1,2] and receive the command "right"
  23. you will be moved to position [1,0]./
  24.  
  25. You need at least 20 tons of fish to be considered a successful season.
  26. Keep in mind that even if the quota is reached the ship continues to move.
  27.  
  28.  
  29. Input
  30. • On the first line, you are given the integer n – the size of the square matrix.
  31. • The next n lines hold the values for every row.
  32. • On each of the next lines, you will get a move command.
  33.  
  34. Output
  35. • On the first line:
  36.  If the ship falls into a whirlpool, print only this message and stop the program:
  37. o "You fell into a whirlpool! The ship sank and you lost the fish you caught. Last coordinates of the ship: [n,n]"
  38.  
  39.  If the ship reaches the quota:
  40. o "Success! You managed to reach the quota!"
  41.  
  42.  If the ship did not reach the quota:
  43. o "You didn't catch enough fish and didn't reach the quota! You need {lack of fish} tons of fish more."
  44.  
  45. • On the next lines.
  46.  If the catch quantity is bigger than zero, print:
  47. o "Amount of fish caught: {quantity} tons."
  48.  
  49. else: do not print anything.
  50.  
  51.  If you didn't get into a whirlpool, print the matrix.
  52. Constraints
  53. • The size of the square matrix will be between [2…10].
  54. • Only the letters 'S' and 'W' will be present in the matrix.
  55. • The fish passages are represented by single positive digits /tons/ between [1…9].
  56. • It is expected that there will only be either zero or one whirpool present, marked with the letter - 'W'.
  57. • Your position will be marked with 'S'.
  58. Examples
  59.  
  60. Input
  61. 4
  62. ---S
  63. ----
  64. 9-5-
  65. 34--
  66. down
  67. down
  68. right
  69. down
  70. collect the nets
  71.  
  72.  
  73. Output
  74. You didn't catch enough fish and didn't reach the quota! You need 8 tons of fish more.
  75. Amount of fish caught: 12 tons.
  76. ----
  77. ----
  78. --5-
  79. S4--
  80.  
  81.  
  82. Comment
  83. The first command is "down".
  84. The ship moves to position [1,3] followed by the command "down" [2,3] and then the command "right".
  85. The ship leaves the matrix's boundaries and transfers to the opposite side at position [2,0].
  86. The ship comes across a fish passage with a quantity of 9 tons and gets it.
  87. After executing the third command, the fishing area will appear as follows:
  88. ----
  89. ----
  90. S-5-
  91. 34--
  92. Then you receive the command "down" again. You move to the passage of 3 tons and add them to the others 9.
  93. Your catch is 9 + 3 = 12 tons. In the end, you get the command "collect the nets" and the program ends.
  94.  
  95.  
  96.  
  97. Input
  98. 5
  99. S---9
  100. 777-1
  101. W333-
  102. 11111
  103. -----
  104. down
  105. down
  106. right
  107. down
  108. collect the nets
  109.  
  110.  
  111. Output
  112. You fell into a whirlpool! The ship sank and you lost the fish you caught. Last coordinates of the ship: [2,0]
  113.  
  114.  
  115. Comment
  116. The first command is "down". The ship moves to position [1,0] and gets 7 tons of fish.
  117. Follow the command "down" -> [2,0] The ship falls into a whirlpool and sinks.
  118. You lose the entire catch and the program ends.
  119.  
  120.  
  121. Input
  122. 5
  123. S---9
  124. 777-1
  125. --5--
  126. 11W11
  127. 988--
  128. down
  129. down
  130. down
  131. down
  132. down
  133. down
  134. right
  135. right
  136. right
  137. collect the nets
  138.  
  139.  
  140. Output
  141. Success! You managed to reach the quota!
  142. Amount of fish caught: 31 tons.
  143. ----9
  144. ---S1
  145. --5--
  146. -1W11
  147. -88--
  148.  
  149.  
  150. Comment
  151. Result is: 7 + 1 + 9 +7 + 7 = 31. You succeeded!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement