Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This code is from a method, so we count that
- # n is pre-defined and passed try:except block.
- # Moreover we are talking about the algorithm,
- # not about the whole Test Task itself
- RECT = '#' # rectangle 'color'
- CIRCB = '*' # circle border 'color'
- CIRCF = 'o' # circle fill 'color'
- # Upper block before the circle
- flag = (
- (3 * n + 2) * RECT + '\n' + RECT +
- (n / 2) * ((3 * n) * ' ' + RECT + '\n' + RECT))
- reverse = False
- onRadius = 1
- # Middle block with circle (not a Bresenham circle drawing algorithm tho)
- for x in range(0, n):
- flag += n * ' '
- fill = onRadius * 2 - 2
- space = (n - fill - 2) / 2
- flag += space * ' ' + CIRCB + fill * CIRCF + CIRCB + space * ' '
- if x < (n / 2) - 1:
- onRadius += 1
- else:
- if not reverse:
- onRadius += 1
- reverse = True
- onRadius -= 1
- flag += n * ' ' + RECT + '\n' + RECT
- flag += (
- (n / 2) * ((3 * n) * ' ' + RECT + '\n' + RECT) +
- (3 * n + 1) * RECT)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement