Yin and yang: Difference between revisions

Line 100:
=={{header|Python}}==
For positive integer n > 0, the following generates an ASCII representation of the Yin yang symbol.
{{works with|Python|3.x}}
<lang python>def yinyang(n=3):
<lang python>import math
<lang python>def yinyang(n=3):
radii = [i * n for i in (1, 3, 6)]
ranges = [list(range(-r, r+1)) for r in radii]
Line 106 ⟶ 108:
for rnge in ranges]
circles = [[ (x,y) for x,y in sqrpoints
if math.hypot(x*x + y*,y)**0.5 <= radius ]
for sqrpoints, radius in zip(squares, radii)]
m = {(x,y):' ' for x,y in squares[-1]}
Line 119 ⟶ 121:
m[(x,y+3*n)] = '·'
m[(x,y-3*n)] = '*'
return '\n'.join(''.join(m[(x,y)] for x in reversed(ranges[-1].__reversed__()) for y in ranges[-1])</lang>
 
;Sample generated symbols for <code>n = 2</code> and <code>n = 3</code>:
Anonymous user