1 # The Great Computer Language Shootout
2 # http://shootout.alioth.debian.org/
4 # contributed by Gabriele Renzi
9 @z = Transformation
.new
1,0,0,1
10 @x = Transformation
.new
0,0,0,0
11 @inverse = Transformation
.new
0,0,0,0
20 @z = consume
@x.next!()
26 digit
== @z.extract(4)
30 @inverse.qrst(10,-10*i
,0,1).compose(@z)
40 attr_reader
:q, :r, :s, :t
41 def initialize (q
, r
, s
, t
)
42 @q,@r,@s,@t,@k = q
,r
,s
,t
,0
54 (@q * j
+ @r) / (@s * j
+ @t)
58 self.class.new( @q * a
.q
,
78 digits
= PiDigitSpigot
.new
82 WIDTH
.times
{print digits
.next!}
85 n
.times
{print digits
.next!}
86 (WIDTH-n
).times
{print
" "}