Advertisement
Nenogzar

02_ball_in_the_bucket

Jun 13th, 2024
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. board, size = [], 6
  2. coordinates_of_B = []
  3. shots_range = 3
  4.  
  5. for r in range(size):
  6.     line = input().split(" ")
  7.     line = [int(el) if el.isdigit() else el for el in line]
  8.     board.append(line)
  9.  
  10.     for c, el in enumerate(line):
  11.         if el == "B":
  12.             coordinates_of_B.append((r, c))
  13.             board[r][c] = 0
  14.  
  15. total_points = 0
  16. hit_buckets = set()
  17. for _ in range(shots_range):
  18.     x, y = input().strip("()").split(", ")
  19.     x, y = int(x), int(y)
  20.  
  21.     if (x, y) in coordinates_of_B and (x, y) not in hit_buckets:
  22.         hit_buckets.add((x, y))
  23.         column_sum = sum(board[r][y] for r in range(size))
  24.         total_points += column_sum
  25.  
  26. if total_points >= 300:
  27.     prize = "Lego Construction Set"
  28. elif 200 <= total_points < 300:
  29.     prize = "Teddy Bear"
  30. elif 100 <= total_points < 200:
  31.     prize = "Football"
  32. else:
  33.     prize = None
  34.  
  35.  
  36. if total_points < 100:
  37.     needed_points = 100 - total_points
  38.     print(f"Sorry! You need {needed_points} points more to win a prize.")
  39. else:
  40.     print(f"Good job! You scored {total_points} points, and you've won {prize}.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement