I am try to help my daughter:

Problem

father is 4 times older then his daughter.

in 6 years he will be 3 times older what is the answer and how did you

reach it.

Thanks, a mom in CA

I am try to help my daughter:

Problem

father is 4 times older then his daughter.

in 6 years he will be 3 times older what is the answer and how did you

reach it.

Thanks, a mom in CA

On Feb 26, 1:28 pm, [email protected] wrote:

I am try to help my daughter:

Problemfather is 4 times older then his daughter.

in 6 years he will be 3 times older what is the answer and how did you

reach it.

Thanks, a mom in CA

This is not the right forum to ask…anyway I can answer this question

Father is 4 times older then his daugher. so the first equation will

be:

Equation 1: Father = 4 * Daughter

In 6 years he will be 3 times older. so the second equation will be:

Equation 2: (Father + 6) = 3 * (Daughter + 6)

Solve equation 1 and 2

In equation 2; replace ‘Father’ by ‘4 * Daughter’ (by equation 1)

so equation 2 can be written as:

(4Daughter + 6) = 3Daughter + 18

4Daughter - 3Daughter = 18 - 6

Daughter = 12

Present Daughter age is 12

Father present age is : 4 * Daughter age = 4 * 12 = 48

ycsunil schrieb:

Father is 4 times older then his daugher. so the first equation will

be:Equation 1: Father = 4 * Daughter

In 6 years he will be 3 times older. so the second equation will be:

Equation 2: (Father + 6) = 3 * (Daughter + 6)

Depends on how you interpret “4 times older”. What if it’d say “the

brother is one time older than the sister”? Are they equal in age,

a.k.a. twins, or would you suggest he is twice as old?

In case of the latter, we’d have to interpret the whole problem

differently.

Equation 1: Father = Daughter + 4*Daughter

Equation 2: Father+6 = Daughter+6 + 3*(Daughter+6)

=> Father = 5*Daughter,
5*Daughter+6=Daughter+6+3*Daughter+18

=> Daughter = 18

=> Father = 90

Well … be Father with 72 … Charlie Chaplin then?

- Matthias

Hi,

On Tue, Feb 26, 2008 at 7:29 PM, [email protected] wrote:

Thanks, a mom in CA

Where is CA, anyway? Not everyone lives in the US.

Arlen

Damn, I was always thought that Math was exact and unambiguous. I want

my

money back!

Arlen C. wrote:

Hi,

On Tue, Feb 26, 2008 at 7:29 PM, [email protected] wrote:

Thanks, a mom in CA

Where is CA, anyway? Not everyone lives in the US.

Arlen

That’s California - the very most western part of the country.

On 2/26/08, pat eyler [email protected] wrote:

On Tue, Feb 26, 2008 at 8:37 AM, Shandy N. [email protected] wrote:

Where is CA, anyway? Not everyone lives in the US.

That’s California - the very most western part of the country.

Unless it’s Canada, in which case British Columbia is the very most

western part of the country. ;^)(I’ll also ignore Hawai’i and Alaska – one joke at a time, that’s

my motto)

Actually, California isn’t even the westernmost state in the lower 48

states. That distinction goes to Oregon.

–

Rick DeNatale

My blog on Ruby

http://talklikeaduck.denhaven2.com/

On Tue, Feb 26, 2008 at 2:29 AM, [email protected] wrote:

I am try to help my daughter:

Problem

in 6 years he will be 3 times older what is the answer and how did you

reach it.

Thanks, a mom in CA

Here’s a matrix solution…

require ‘matrix’

coefficient_matrix = Matrix[[1, -4], [1, -3]]

solution_vector = [[0], [12]]

father_age, daughter_age = (coefficient_matrix.inverse *

solution_vector).to_a.flatten

=> [48, 12]

Let x be father’s age, y be daughter’s

x = 4y

x + 6 = 3(y + 6)

Simplified and with x’s and y’s on one side.

x - 4y = 0

x - 3y = 12

The coefficients make up the matrix [[1, -4], [1, -3]], with the

current solution vector as [[0], [12]].

Multiply both sides by the inverse of the coefficient matrix will give

you the identity matrix on the left side and the solution vector on

the right.

cheers,

Todd

On Tue, Feb 26, 2008 at 11:58 AM, Todd B. [email protected]

wrote:

Here’s a matrix solution…

require ‘matrix’

coefficient_matrix = Matrix[[1, -4], [1, -3]]

solution_vector = [[0], [12]]

Oops, that line was supposed to be…

solution_vector = Matrix[[0], [12]]

Todd

On Tue, Feb 26, 2008 at 8:37 AM, Shandy N. [email protected]

wrote:

Arlen

That’s California - the very most western part of the country.

Unless it’s Canada, in which case British Columbia is the very most

western part of the country. ;^)

(I’ll also ignore Hawai’i and Alaska – one joke at a time, that’s

my motto)

On Tue, Feb 26, 2008 at 8:26 AM, Rick DeNatale [email protected]

wrote:

western part of the country. ;^)

(I’ll also ignore Hawai’i and Alaska – one joke at a time, that’s

my motto)Actually, California isn’t even the westernmost state in the lower 48

states. That distinction goes to Oregon.

The48 contiguous states haven’t really been the “lower 48” since

Hawai’i was admitted, either. (Though I suppose if you meant the 48

states that aren’t Alaska and Maine, what you said would still be

true.)

Rick DeNatale wrote:

Actually, California isn’t even the westernmost state in the lower 48

states. That distinction goes to Oregon.

Actually, it goes to Washington, I think – Cape Alava, IIRC. But not by

much.

On 2/26/08, Christopher D. [email protected] wrote:

On Tue, Feb 26, 2008 at 8:26 AM, Rick DeNatale [email protected] wrote:

states. That distinction goes to Oregon.The48 contiguous states haven’t really been the “lower 48” since

Hawai’i was admitted, either. (Though I suppose if you meant the 48

states that aren’t Alaska and Maine, what you said would still be

true.)

Only if you spell Maine as Hawaii.

–

Rick DeNatale

My blog on Ruby

http://talklikeaduck.denhaven2.com/

On 26/02/2008, [email protected] [email protected] wrote:

I am try to help my daughter:

Problemfather is 4 times older then his daughter.

in 6 years he will be 3 times older what is the answer and how did you

reach it.

48 and 12

def all_conditions(f,d)

f == 4*d and f+6 == (d+6)*3

end

loop do

daughter = rand(father = rand(100))

if all_conditions(father,daughter)

puts “father: #{father} daughter: #{daughter}”

break

end

end

On 2/26/08, M. Edward (Ed) Borasky [email protected] wrote:

Rick DeNatale wrote:

states. That distinction goes to Oregon.Actually, it goes to Washington, I think – Cape Alava, IIRC. But not by

much.

And somewhat controversially. Also Cape Alava seems only to be

westernmost at low tide if we’re talking about the mainland.

An interesting fact is that if we define easternmost/westernmost by

longitude, Alaska takes three of the four championships. It is the

northernmost, westernmost, AND easternmost state.

–

Rick DeNatale

My blog on Ruby

http://talklikeaduck.denhaven2.com/

2008/2/27, Rick DeNatale [email protected]:

Not exactly the fastest way to do it empirically, why random.

(…)

Rick, are you sure?

class String

alias :to_int :to_i

end

def init_counts

zero = %w((?=…||t) /).inject(“C:4<NDC2?5NSQPUtr/-|^-|/-]”

){|a,e|(a=a.split(/#{e}/)).shift.send(*a)}

@counts = Hash.new(zero)

end

def count(name)

@counts[name] += 1

end

def show_counts

puts

@counts.each do |name, count|

printf(“%s: %d loops\n”, name, count)

end

end

def all_conditions(f,d)

f == 4*d and f+6 == (d+6)*3

end

def thomas_search

loop do

count(:thomas)

daughter = rand(father = rand(100))

if all_conditions(father,daughter)

puts “father: #{father} daughter: #{daughter}”

break

end

end

end

def rick_search

d = 0

begin

count(:rick)

d += 1

end until (f = 4*d) && (f + 6) == (d + 6) * 3

puts “Father is #{f} years old, Daughter is #{d}.”

end

init_counts

thomas_search

rick_search

show_counts

Running this I get:

father: 48 daughter: 12

Father is 48 years old, Daughter is 12.

thomas: 1 loops

rick: 12 loops

Regards,

Pit

On 2/27/08, Pit C. [email protected] wrote:

2008/2/27, Rick DeNatale [email protected]:

Not exactly the fastest way to do it empirically, why random.

(…)

Rick, are you sure?

Well except in the case where some ZERO cleverly seeds the random

number generator to produce the right random numbers, yes! A very

slight modification:

def init_counts

zero = 0

@counts = Hash.new(zero)

end

produces:

father: 48 daughter: 12

Father is 48 years old, Daughter is 12.

rick: 12 loops

thomas: 19467 loops

Of course, being random, the thomas count varies, while the rick count

stays at 12.

And then I much prefer the algebraic solution I worked out in a few

seconds on paper when the question was first posed.

I leave to others the pleasure of discovering the details of your trick.

–

Rick DeNatale

My blog on Ruby

http://talklikeaduck.denhaven2.com/

On 2/27/08, Thomas P. [email protected] wrote:

`break`

end

end

Not exactly the fastest way to do it empirically, why random.

d = 0

d += 1 until (f = 4*d) && (f + 6) == (d + 6) * 3

puts “Father is #{f} years old, Daughter is #{d}.”

–

Rick DeNatale

My blog on Ruby

http://talklikeaduck.denhaven2.com/

<…>

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’

=> truerequire ‘rational’

=> truek = 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

c = Matrix[[Rational(0)],[Rational(12)]]

=> Matrix[[Rational(0, 1)], [Rational(12, 1)]]

Copied from the wrong place, these of course should be:

c = Matrix[[Rational(0)],[Rational(-12)]]

=> Matrix[[Rational(0, 1)], [Rational(-12, 1)]]

Regards,

Rimantas

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs