Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 1.15 KB

cat_years_dog_years.md

File metadata and controls

46 lines (36 loc) · 1.15 KB

Description

Kata Task

I have a cat and a dog.

I got them at the same time as kitten/puppy. That was humanYears years ago.

Return their respective ages now as [humanYears, catYears, dogYears]

NOTES:

  • humanYears >= 1
  • humanYears are whole numbers only

Cat Years

  • 15 cat years for first year
  • +9 cat years for second year
  • +4 cat years for each year after that

Dog Years

  • 15 dog years for first year
  • +9 dog years for second year
  • +5 dog years for each year after that

References


If you liked this Kata there is another related one here

My Solution

def human_years_cat_years_dog_years(human_years)
  if human_years == 1
    [1,15,15]
  elsif human_years == 2
    [2, 24, 24]
  else
    [human_years, 24 + (human_years-2)*4, 24 + (human_years-2)*5]
  end
end