Problem of Apollonius: Difference between revisions

Content added Content deleted
m (→‎{{header|Perl}}: all 8 solutions)
m (→‎{{header|Perl 6}}: all 8 solutions, nicer output)
Line 1,948: Line 1,948:
has $.y;
has $.y;
has $.r;
has $.r;
method gist { "circle($!x, $!y, $!r)" }
method gist { sprintf "%s =%7.3f " xx 3, (:$!x,:$!y,:$!r)».kv }
}
}


Line 1,992: Line 1,992:
}
}
@c = circle(0, 0, 1), circle(4, 0, 1), circle(2, 4, 2);
sub MAIN {
for ([X] [-1,1] xx 3) -> @i {
my @c = circle(0, 0, 1), circle(4, 0, 1), circle(2, 4, 2);
say solve-Apollonius @c, <1 1 1>;
say (solve-Apollonius @c, @i).gist;
say solve-Apollonius @c, <-1 -1 -1>;
}</lang>
}</lang>
{{out}}
{{out}}
<pre>circle(2, 2.1, 3.9)
<pre>x = 2.000 y = 0.833 r = 1.167
x = 2.000 y = 3.214 r = 2.786
circle(2, 0.833333333333333, 1.16666666666667)</pre>
x = 3.002 y = 0.123 r = 2.005
x = 4.127 y = 3.252 r = 4.255
x = 0.998 y = 0.123 r = 2.005
x = -0.127 y = 3.252 r = 4.255
x = 2.000 y = -1.500 r = 3.500
x = 2.000 y = 2.100 r = 3.900</pre>


=={{header|PL/I}}==
=={{header|PL/I}}==