Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

140 lines
2.7 KiB
Markdown

---
id: 699c8e045ee7cb94ed2322da
title: "Challenge 219: Anniversary Milestones"
challengeType: 29
dashedName: challenge-219
---
# --description--
Given an integer representing the number of years a couple has been married, return their most recent anniversary milestone according to this chart:
| Years Married | Milestone |
| ------------- | ------------ |
| 1 | `"Paper"` |
| 5 | `"Wood"` |
| 10 | `"Tin"` |
| 25 | `"Silver"` |
| 40 | `"Ruby"` |
| 50 | `"Gold"` |
| 60 | `"Diamond"` |
| 70 | `"Platinum"` |
- If they haven't reached the first milestone, return `"Newlyweds"`.
# --hints--
`get_milestone(0)` should return `"Newlyweds"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(0), "Newlyweds")`)
}})
```
`get_milestone(1)` should return `"Paper"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(1), "Paper")`)
}})
```
`get_milestone(8)` should return `"Wood"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(8), "Wood")`)
}})
```
`get_milestone(10)` should return `"Tin"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(10), "Tin")`)
}})
```
`get_milestone(26)` should return `"Silver"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(26), "Silver")`)
}})
```
`get_milestone(45)` should return `"Ruby"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(45), "Ruby")`)
}})
```
`get_milestone(50)` should return `"Gold"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(50), "Gold")`)
}})
```
`get_milestone(64)` should return `"Diamond"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(64), "Diamond")`)
}})
```
`get_milestone(71)` should return `"Platinum"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_milestone(71), "Platinum")`)
}})
```
# --seed--
## --seed-contents--
```py
def get_milestone(years):
return years
```
# --solutions--
```py
def get_milestone(years):
if years < 1:
return "Newlyweds"
milestones = [
(1, "Paper"),
(5, "Wood"),
(10, "Tin"),
(25, "Silver"),
(40, "Ruby"),
(50, "Gold"),
(60, "Diamond"),
(70, "Platinum")
]
for year, milestone in reversed(milestones):
if years >= year:
return milestone
```