import math BEGIN = math.pi / 2 SIZE = 4 def func(s): l = len(s) r = int(int(l / (math.pi * 2) + 1) * SIZE) h = r * 2 + 1 theta = (2 * math.pi) / l output = [['.' for j in range(h)] for i in range(h)] for i in range(l): y = r - int(round(r * math.sin(BEGIN - theta * i))) x = r + int(round(r * math.cos(BEGIN - theta * i))) output[y][x] = s[i] for i in range(h): for j in range(h): print(output[i][j], end="") print() func("C123456789AB") func("++++++++++++++++++++++++++++++++")
Standard input is empty
........C........ ....B.......1.... ................. ................. .A.............2. ................. ................. ................. 9...............3 ................. ................. ................. .8.............4. ................. ................. ....7.......5.... ........6........ ...................+....+....+................... ................................................. ...............+.................+............... ................................................. ...........+.........................+........... ................................................. ................................................. .......+.................................+....... ................................................. ................................................. ................................................. ....+.......................................+.... ................................................. ................................................. ................................................. ..+...........................................+.. ................................................. ................................................. ................................................. +...............................................+ ................................................. ................................................. ................................................. ................................................. +...............................................+ ................................................. ................................................. ................................................. ................................................. +...............................................+ ................................................. ................................................. ................................................. ..+...........................................+.. ................................................. ................................................. ................................................. ....+.......................................+.... ................................................. ................................................. ................................................. .......+.................................+....... ................................................. ................................................. ...........+.........................+........... ................................................. ...............+.................+............... ................................................. ...................+....+....+...................