From: ThoML Date: 2008-06-16T00:09:16+09:00 Subject: Re: Circle Drawing (#166) My solution makes circles with r=7 14 characters wide. This may be incorrect. It's rather simple though. Regards, Thomas. def draw_circle(r, ratio=1.0) lines = [] a = 0.0 t2 = ratio / 2.0 (t2 - 0.1).step(r, ratio) do |h| b = Math.sqrt(2.0 * h * r - h ** 2).round u = r - b v = [1.0, b - a].max w = (r - u - v) * 2.0 lines << [(m = ' ' * u), (l = '#' * v), ' ' * w, l, m].join a = b end out = lines.join("\n") puts out puts out.reverse end if __FILE__ == $0 draw_circle(*ARGV.map {|e| e.to_f}) end