Advertisement
Guest User

Untitled

a guest
Jan 8th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. # This code is from a method, so we count that
  2. # n is pre-defined and passed try:except block.
  3. # Moreover we are talking about the algorithm,
  4. # not about the whole Test Task itself
  5.  
  6. RECT = '#'  # rectangle 'color'
  7. CIRCB = '*' # circle border 'color'
  8. CIRCF = 'o' # circle fill 'color'
  9.  
  10. # Upper block before the circle
  11. flag = (
  12.     (3 * n + 2) * RECT + '\n' + RECT +
  13.     (n / 2) * ((3 * n) * ' ' + RECT + '\n' + RECT))
  14.  
  15. reverse = False
  16. onRadius = 1
  17.  
  18. # Middle block with circle (not a Bresenham circle drawing algorithm tho)
  19. for x in range(0, n):
  20.         flag += n * ' '
  21.  
  22.         fill = onRadius * 2 - 2
  23.         space = (n - fill - 2) / 2
  24.         flag += space * ' ' + CIRCB + fill * CIRCF + CIRCB + space * ' '
  25.         if x < (n / 2) - 1:
  26.             onRadius += 1
  27.         else:
  28.             if not reverse:
  29.                 onRadius += 1
  30.                 reverse = True
  31.             onRadius -= 1
  32.  
  33.         flag += n * ' ' + RECT + '\n' + RECT
  34.  
  35. flag += (
  36.     (n / 2) * ((3 * n) * ' ' + RECT + '\n' + RECT) +
  37.     (3 * n + 1) * RECT)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement