Cracking the Coding Interview: Fourth Edition (308 page e-book / PDF)
Delivered instantly as a PDF via email. For Software Engineers & SDETs
  • 150 programming interview questions and answers
  • 5 proven approaches to crack algorithm questions
  • 10 mistakes candidates make, and how to avoid them.
  • How to prepare for technical and behavioral questions without wasting your time!
"The BEST book for acing your interview. It helped me land my Microsoft job, and it was worth every penny!" - Ravi (Accepted at Microsoft, Amazon and Facebook) 30 Day Money Back Guarantee: Don't love the book? We'll give you your money back! More Info

Wednesday, April 28, 2010

Father's age

Father's age is three years more than three times the son's age.After three years, father's age will be ten years more than twice the son's age. What is the father's present age?


Ans:
33 years.

18 comments:

  1. f = 3s+3
    f+3=2(s+3)+10

    f-3s = 3

    f-2(f/3 -1) = 13

    f/3 = 11

    f=33

    ReplyDelete
  2. Its valid for the first condition
    But how about second condition
    where fathers age has to be 10 years more than double the sons age
    Son = 11+ 3=14
    father= 33 + 3= 36
    Twice Sons age = 14 * 2= 28
    Plus Ten = 28 + 10 =38
    But we have fathers age here as 36 ???

    ReplyDelete
  3. Your assumption of Son = "11 + 3" is wrong .. Sons age should be 10 when Father's age was 33.

    Son = 10 + 3 = 13
    father = 33 +3 = 36
    Twice Sons age = 26
    Plus Ten = 26 + 10 = 36

    There you go both match !

    ReplyDelete
  4. Son is not 11, but 10.
    3s+3=Son
    3 * 10 + 3 = 33.

    ReplyDelete
  5. @above:
    Son = 11+ 3=14 --> this is wrong. Read the question carefully. Son is 10.

    ReplyDelete
  6. Hi,

    The correct age of father is 33.

    s=10

    f=33

    After 3 yrs:

    f+3=2(s+3)+10

    subsitute 10 for s

    You get f+3=36

    Father age would be 36 after 3 yrs
    sons age would be 13 after 3 yrs

    Thanks,
    Barani

    ReplyDelete
  7. after 3 years sons age will be 10+3=13 years and fathers will be 33+3=36 ( 13*2 +10) . so it correct.

    ReplyDelete
  8. son's age is not 11, but its 10...
    son = 10 + 3
    father = 33 + 3 = 36
    so, 2*(10+3) + 10 = 36

    ReplyDelete
  9. For the next person who comes to this page, I have no idea where Sharath is getting those numbers.
    Son = 10
    Father = 33
    In three years:
    33+3 = 2(10+3)+10
    36 = 20+6+10, quite correct.

    In fact, let's go over Parijat's calculations (I think this is where Sharath got confused).
    1st condition: F=3S+3
    2nd condition: F+3=2(S+3)+10
    F+3=2S+16
    F=2S+13
    (substitute 3S+3 for F)
    3S+3=2S+13
    3S=2S+10
    S=10 (Son's age right now)
    F=3S+3
    F=30+3
    F=33 (Father's age right now)

    ReplyDelete
  10. The son is 10. Parijat just didn't explicitly state that.

    f = 3s + 3
    f + 3 = 2(s + 3) + 10
    f = 2s + 6 + 10 - 3
    f = 2s + 13

    2s + 13 = 3s + 3
    13 = s + 3
    s = 10

    The 11 above had the +3 in the 3s+3 included in it.

    ReplyDelete
  11. How did you calculate Son's age as 10. If fathers age is 33 then son's age is 10. So this soln is right.

    ReplyDelete
  12. Son's current age is 10 (father is 3 + 3 *s)

    ReplyDelete
  13. Nice post I, really love to reading this kind of information.

    ReplyDelete
  14. Easy. It's a system of equations (think back to high school algebra).

    Let f = current age of father
    s = current age of son

    The father is 3 years more than 3 times the age of the son. Write that as an equation and you have this:
    f = 3 + 3s

    In three years, the father is 10 years more than twice the age of the son.

    Write that as an equation and you have this:
    f + 3 = 10 + 2(s + 3) - because in three years, the son will be 3 years older

    So now you have a system of equations:

    f = 3 + 3s
    f + 3 = 10 + 2(s + 3)

    Simplify the second equation and you have this:
    f + 3 = 10 + 2s + 6
    f + 3 = 16 + 2s
    f = 13 + 2s

    Next substitute the first equation as the value for f in the second equation and you get this:

    3 + 3s = 13 + 2s

    Now you can just simplify and solve for s, like this:

    3 + 3s = 13 + 2s
    -3 -3

    3s = 10 + 2s
    -2s -2s

    s = 10 - this is the current age of the son

    Now you can just substitute s back into the original equation for f, like this:

    f = 3 + 3(10)
    f = 3 + 30
    f = 33

    So, the current age of the father is 33 and the current age of the son is 10.

    Now we can go back and check both conditions:

    f = 3 + 3s
    33 = 3 + 3(10)
    33 = 3 + 30
    33 = 33
    Condition #1 works

    In three years, the father will be 36 and the son will be 13

    36 = 10 + 2(13)
    36 = 10 + 26
    36 = 36
    Condition #2 works

    ReplyDelete
  15. @Sharath:
    It is valid for the second condition also!
    You have considered Son's age as 11, which is actually 10
    So,
    Son = 10+3 = 13
    Father = 33+3 = 36
    Twice Son's age = 13*2 = 26
    Plus 10 = 36

    So it is valid!

    ReplyDelete
  16. Father is 33 years old. It's so simple.

    ReplyDelete