fork download
  1. import math
  2. BEGIN = math.pi / 2
  3. SIZE = 4
  4.  
  5. def func(s):
  6. l = len(s)
  7. r = int(int(l / (math.pi * 2) + 1) * SIZE)
  8. h = r * 2 + 1
  9. theta = (2 * math.pi) / l
  10. output = [['.' for j in range(h)] for i in range(h)]
  11. for i in range(l):
  12. y = r - int(round(r * math.sin(BEGIN - theta * i)))
  13. x = r + int(round(r * math.cos(BEGIN - theta * i)))
  14. output[y][x] = s[i]
  15. for i in range(h):
  16. for j in range(h):
  17. print(output[i][j], end="")
  18. print()
  19.  
  20. func("C123456789AB")
  21. func("++++++++++++++++++++++++++++++++")
Success #stdin #stdout 0.11s 10088KB
stdin
Standard input is empty
stdout
........C........
....B.......1....
.................
.................
.A.............2.
.................
.................
.................
9...............3
.................
.................
.................
.8.............4.
.................
.................
....7.......5....
........6........
...................+....+....+...................
.................................................
...............+.................+...............
.................................................
...........+.........................+...........
.................................................
.................................................
.......+.................................+.......
.................................................
.................................................
.................................................
....+.......................................+....
.................................................
.................................................
.................................................
..+...........................................+..
.................................................
.................................................
.................................................
+...............................................+
.................................................
.................................................
.................................................
.................................................
+...............................................+
.................................................
.................................................
.................................................
.................................................
+...............................................+
.................................................
.................................................
.................................................
..+...........................................+..
.................................................
.................................................
.................................................
....+.......................................+....
.................................................
.................................................
.................................................
.......+.................................+.......
.................................................
.................................................
...........+.........................+...........
.................................................
...............+.................+...............
.................................................
...................+....+....+...................