← Back to challenges

Human, Cat and Dog Years πŸ§‘πŸ»πŸ±πŸΆ

PythonHardnumbersmathlogicinterview

Instructions

Mubashir has a cat and a dog. He purchased both of them at the same time human_years ago.

Create a function which takes an argument of human_years and returns [human_years, cat_years, dog_years] list.

Human Years

  • Human Years >= 1
  • Human Years 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

Examples

calculate_years(1) ➞ [1, 15, 15]

calculate_years(2) ➞ [2, 24, 24]

calculate_years(10) ➞ [10, 56, 64]

Notes

N/A

python3
Loading editor…
⌘ ↡ to run
Walks through the solution with reasoning and edge cases.
Next: Product Divisible by Sum? β†’