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

111 lines
2.1 KiB
Markdown

---
id: 6a26df3e2988bcdded204894
title: "Challenge 358: Emoji Translator"
challengeType: 29
dashedName: challenge-358
---
# --description--
Given a string of emojis, return the phrase using the following table:
| Emoji | Word |
|-------|------|
| 👶 | `"baby"` |
| 🐱 | `"cat"` |
| 🐕 | `"dog"` |
| 🐟 | `"fish"` |
| 🥵 | `"hot"` |
| 🧊 | `"ice"` |
| 🪨 | `"rock"` |
| 🦈 | `"shark"` |
| 🍲 | `"soup"` |
| ⭐ | `"star"` |
Return the words separated by spaces.
# --hints--
`get_emoji_phrase("🪨⭐")` should return `"rock star"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("🪨⭐"), "rock star")`)
}})
```
`get_emoji_phrase("🥵🐕")` should return `"hot dog"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("🥵🐕"), "hot dog")`)
}})
```
`get_emoji_phrase("👶🦈")` should return `"baby shark"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("👶🦈"), "baby shark")`)
}})
```
`get_emoji_phrase("⭐🐟")` should return `"star fish"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("⭐🐟"), "star fish")`)
}})
```
`get_emoji_phrase("🧊🧊👶")` should return `"ice ice baby"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("🧊🧊👶"), "ice ice baby")`)
}})
```
`get_emoji_phrase("🐱🐟🍲")` should return `"cat fish soup"`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("🐱🐟🍲"), "cat fish soup")`)
}})
```
# --seed--
## --seed-contents--
```py
def get_emoji_phrase(s):
return s
```
# --solutions--
```py
def get_emoji_phrase(s):
table = {
'👶': 'baby',
'🐱': 'cat',
'🐕': 'dog',
'🐟': 'fish',
'🥵': 'hot',
'🧊': 'ice',
'🪨': 'rock',
'🦈': 'shark',
'🍲': 'soup',
'⭐': 'star',
}
return ' '.join(table[emoji] for emoji in s)
```