📘
Word-Level Translator
Given a word-level translation dictionary and a source sentence, translate each word. If a word is not in the dictionary, keep it unchanged.
Input format:
- Line 1: Number of dictionary entries
- Next n lines: "source_word target_word"
- Last line: Source sentence to translate
All matching is case-insensitive, but output the translation in its original form from the dictionary.
Example:
Input:
3 hello hola world mundo good bueno hello world
Output:
hola mundo
Reasoning:
Step 1: Build dictionary hello → hola, world → mundo, good → bueno
Step 2: Translate each word "hello" → found: "hola" "world" → found: "mundo"
Result: "hola mundo"
Constraints:
- Case-insensitive lookup
- Unknown words kept as-is
- Output: Translated sentence
Editor
Python 3.13.1
Test Results
0/0Run code to see test results.