Advertisement
ALEXANDAR_GEORGIEV

diamont

Jun 10th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. from math import floor
  2. num_row = int(input())
  3. count_row_symbols = num_row
  4. if not num_row % 2:
  5.     count_stars_first_row = 2
  6.     num_row -= 1
  7.     midd_space = 2
  8. else:
  9.     count_stars_first_row = 1
  10.     midd_space = 1
  11. next_num_row = num_row - 1
  12. # First row
  13. count_space_left = int((num_row - 1) / 2)    # 1-vi red
  14. print('-' * count_space_left + '*' * count_stars_first_row + '-' * count_space_left)
  15. # Next rows
  16. for row in range(1, next_num_row):
  17.     if row <= floor(num_row / 2):
  18.         count_space_left -= 1
  19.         count_space_right = count_space_left
  20.         print('-' * count_space_left + '*' + '-' * midd_space + '*' + '-' * count_space_right)
  21.         midd_space += 2
  22.  
  23.     else:
  24.         if row == floor((num_row / 2)) + 1:
  25.             midd_space -= 4
  26.         count_space_left += 1
  27.         count_space_right = count_space_left
  28.         print('-' * count_space_left + '*' + '-' * midd_space + '*' + '-' * count_space_right)
  29.         midd_space -= 2
  30. # Last row
  31. if num_row >2:
  32.     count_space_left = int((num_row - 1) / 2)    # 1-vi red
  33.     print('-' * count_space_left + '*' * count_stars_first_row + '-' * count_space_left)
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement