Advertisement
Guest User

qwerty

a guest
Dec 9th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.96 KB | None | 0 0
  1. inp = open("input.txt", "r")
  2.  
  3. l, r, e = map(int, inp.read().split())
  4.  
  5. inp.close()
  6.  
  7. n = 0
  8. for i in range(l):
  9.     n += r + e + 1 - i
  10. n = (n - 1) * 2 + 1
  11.  
  12. row = ["."] * n
  13. mas = []
  14. for i in range(n):
  15.     mas.append(row.copy())
  16.  
  17.  
  18. def just_a_recursion(x, y, l, r, e, dir = "all"):
  19.     if l == 0:
  20.         return
  21.  
  22.     if mas[y][x] != ".":
  23.         mas[y][x] = "x"
  24.     else:
  25.         mas[y][x] = "*"
  26.     for i in range(1, r + e + 1):
  27.         if dir != "right" and mas[y][x + i] != ".":
  28.             mas[y][x + i] = "x"
  29.         elif dir != "right":
  30.             mas[y][x + i] = "-"
  31.         if dir != "left" and mas[y][x - i] != ".":
  32.             mas[y][x - i] = "x"
  33.         elif dir != "left":
  34.             mas[y][x - i] = "-"
  35.         if dir != "down" and mas[y + i][x] != ".":
  36.             mas[y + i][x] = "x"
  37.         elif dir != "down":
  38.             mas[y + i][x] = "|"
  39.         if dir != "up" and mas[y - i][x] != ".":
  40.             mas[y - i][x] = "x"
  41.         elif dir != "up":
  42.             mas[y - i][x] = "|"
  43.     for i in range(1, r + 1):
  44.         if mas[y + i][x + i] != ".":
  45.             mas[y + i][x + i] = "x"
  46.         else:
  47.             mas[y + i][x + i] = "\\"
  48.         if mas[y - i][x - i] != ".":
  49.             mas[y - i][x - i] = "x"
  50.         else:
  51.             mas[y - i][x - i] = "\\"
  52.         if mas[y - i][x + i] != ".":
  53.             mas[y - i][x + i] = "x"
  54.         else:
  55.             mas[y - i][x + i] = "/"
  56.         if mas[y + i][x - i] != ".":
  57.             mas[y + i][x - i] = "x"
  58.         else:
  59.             mas[y + i][x - i] = "/"
  60.  
  61.     if dir == "down":
  62.         just_a_recursion(x + r + e + 1, y, l - 1, r - 1, e, "left")
  63.         just_a_recursion(x - r - e - 1, y, l - 1, r - 1, e, "right")
  64.         just_a_recursion(x, y - r - e - 1, l - 1, r - 1, e, "down")
  65.     elif dir == "left":
  66.         just_a_recursion(x + r + e + 1, y, l - 1, r - 1, e, "left")
  67.         just_a_recursion(x, y + r + e + 1, l - 1, r - 1, e, "up")
  68.         just_a_recursion(x, y - r - e - 1, l - 1, r - 1, e, "down")
  69.     elif dir == "up":
  70.         just_a_recursion(x + r + e + 1, y, l - 1, r - 1, e, "left")
  71.         just_a_recursion(x, y + r + e + 1, l - 1, r - 1, e, "up")
  72.         just_a_recursion(x - r - e - 1, y, l - 1, r - 1, e, "right")
  73.     elif dir == "right":
  74.         just_a_recursion(x, y + r + e + 1, l - 1, r - 1, e, "up")
  75.         just_a_recursion(x - r - e - 1, y, l - 1, r - 1, e, "right")
  76.         just_a_recursion(x, y - r - e - 1, l - 1, r - 1, e, "down")
  77.     else:
  78.         just_a_recursion(x + r + e + 1, y, l - 1, r - 1, e, "left")
  79.         just_a_recursion(x, y + r + e + 1, l - 1, r - 1, e, "up")
  80.         just_a_recursion(x - r - e - 1, y, l - 1, r - 1, e, "right")
  81.         just_a_recursion(x, y - r - e - 1, l - 1, r - 1, e, "down")
  82.  
  83. just_a_recursion(n//2, n//2, l, r, e)
  84.  
  85. out = open("output.txt", "w")
  86. newline = "\n"
  87.  
  88. for i in range(n):
  89.     if i == n-1: newline = ""
  90.     line = ""
  91.     for j in mas[i]:
  92.         line += j
  93.     out.write(line + newline)
  94.  
  95. out.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement