Back to Practice
#0143

Age Ratio After Years

MediumAptitude25 min20 XP

Problem

A is 4 years older than B. After 6 years, their ages will be in ratio 5:4. Find present ages.

Why This Matters

Age questions train translating words into equations.

Examples

Example 1
InputA older by 4; future ratio 5:4
OutputA=14, B=10

The ratio applies to future ages, not present ages.

Constraints

  • Return the exact requested structure.
  • Handle normal edge cases cleanly.
  • Prefer readable code over clever shortcuts.
CodeReasoning
A is 4 years older than B. After 6 years, their ages will be in ratio 5:4. Find present ages.
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
InputA older by 4; future ratio 5:4
ExpectedA=14, B=10

The ratio applies to future ages, not present ages.

Hidden Test Categories
past ratiothree peoplefind difference