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

2.1 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
6a26df3e2988bcdded204894 Challenge 358: Emoji Translator 29 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".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("🪨⭐"), "rock star")`)
}})

get_emoji_phrase("🥵🐕") should return "hot dog".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("🥵🐕"), "hot dog")`)
}})

get_emoji_phrase("👶🦈") should return "baby shark".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("👶🦈"), "baby shark")`)
}})

get_emoji_phrase("⭐🐟") should return "star fish".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("⭐🐟"), "star fish")`)
}})

get_emoji_phrase("🧊🧊👶") should return "ice ice baby".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("🧊🧊👶"), "ice ice baby")`)
}})

get_emoji_phrase("🐱🐟🍲") should return "cat fish soup".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_emoji_phrase("🐱🐟🍲"), "cat fish soup")`)
}})

--seed--

--seed-contents--

def get_emoji_phrase(s):

    return s

--solutions--

def get_emoji_phrase(s):
    table = {
        '👶': 'baby',
        '🐱': 'cat',
        '🐕': 'dog',
        '🐟': 'fish',
        '🥵': 'hot',
        '🧊': 'ice',
        '🪨': 'rock',
        '🦈': 'shark',
        '🍲': 'soup',
        '⭐': 'star',
    }
    return ' '.join(table[emoji] for emoji in s)