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