dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.9 KiB
1.9 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 6a2037a68a0bc2aef0006000 | Challenge 338: Pet Age Calculator | 29 | challenge-338 |
--description--
Given a pet type and age in human years, return the equivalent age in pet years using the following conversion table:
| Pet | Multiplier |
|---|---|
"dog" |
7 |
"cat" |
6 |
"rabbit" |
8 |
"hamster" |
30 |
"guinea pig" |
12 |
"goldfish" |
6 |
"bird" |
5 |
--hints--
pet_years("dog", 5) should return 35.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(pet_years("dog", 5), 35)`)
}})
pet_years("cat", 9) should return 54.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(pet_years("cat", 9), 54)`)
}})
pet_years("rabbit", 3) should return 24.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(pet_years("rabbit", 3), 24)`)
}})
pet_years("hamster", 4) should return 120.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(pet_years("hamster", 4), 120)`)
}})
pet_years("guinea pig", 5) should return 60.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(pet_years("guinea pig", 5), 60)`)
}})
pet_years("goldfish", 2) should return 12.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(pet_years("goldfish", 2), 12)`)
}})
pet_years("bird", 1) should return 5.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(pet_years("bird", 1), 5)`)
}})
--seed--
--seed-contents--
def pet_years(pet, age):
return pet
--solutions--
def pet_years(pet, age):
table = {
"dog": 7,
"cat": 6,
"rabbit": 8,
"hamster": 30,
"guinea pig": 12,
"goldfish": 6,
"bird": 5,
}
return age * table[pet]