On Wed, Feb 27, 2008 at 9:25 PM, Rimantas Liubertas <rimantas / gmail.com> wrote:
> <...>
>
> >  And then I much prefer the algebraic solution I worked out in a few
>  >  seconds on paper when the question was first posed.
>  <...>
>
>  Father: x
>  Daugher: y
>  4y - x  = 0
>  (x + 6) / (y+6) = 3   ->   3y + 18 = x + 6   ->   3y - x = -12
>
>  Coefficients:
>  4, -1
>  3, -1
>  Constants
>  0
>  -12
>
>  >> require 'matrix'
>  => true
>  >> require 'rational'
>  => true
>  >> k = Matrix[*[[4, -1], [-3, 1]].map{|r| r.map{|x| Rational(x)}}].inverse
>  => Matrix[[Rational(1, 1), Rational(1, 1)], [Rational(3, 1), Rational(4, 1)]]
>  >> c = Matrix[[Rational(0)],[Rational(12)]]
>  => Matrix[[Rational(0, 1)], [Rational(12, 1)]]
>  >> (k * c).to_a.flatten.map{|e| e.to_i}
>  => [12, 48]
>
>
>  Regards,
>  Rimantas
>  --
>  http://rimantas.com/

Yeah, I would probably use Rational or BigDecimal or even Float, but
for this purpose, Integer seems to work.

Todd