Created
January 13, 2025 18:42
-
-
Save kracekumar/d566633ca59d6f8df5a27bc2686e89e1 to your computer and use it in GitHub Desktop.
Solution to Interview question of the week: https://buttondown.com/cassidoo/archive/believe-in-the-power-of-your-own-voice-al-gore/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NATO_DICTIONARY = { | |
"A": "Alpha", | |
"B": "Bravo", | |
"C": "Charlie", | |
"D": "Delta", | |
"E": "Echo", | |
"F": "Foxtrot", | |
"G": "Golf", | |
"H": "Hotel", | |
"I": "India", | |
"J": "Juliet", | |
"K": "Kilo", | |
"L": "Lima", | |
"M": "Mike", | |
"N": "November", | |
"O": "Oscar", | |
"P": "Papa", | |
"Q": "Quebec", | |
"R": "Romeo", | |
"S": "Sierra", | |
"T": "Tango", | |
"U": "Uniform", | |
"V": "Victor", | |
"W": "Whiskey", | |
"X": "X-ray", | |
"Y": "Yankee", | |
"Z": "Zulu", | |
"0": "Zero", | |
"1": "One", | |
"2": "Two", | |
"3": "Three", | |
"4": "Four", | |
"5": "Five", | |
"6": "Six", | |
"7": "Seven", | |
"8": "Eight", | |
"9": "Nine", | |
" ": "(space)", | |
".": "stop", | |
",": "comma", | |
"-": "hyphen", | |
"/": "slant", | |
"(": "brackets on", | |
")": "brackets off" | |
} | |
def natoify(word): | |
return " ".join(NATO_DICTIONARY[char.upper()] for char in word.strip()) | |
assert natoify('hello world') == "Hotel Echo Lima Lima Oscar (space) Whiskey Oscar Romeo Lima Delta" | |
assert natoify('3spooky5me') == "Three Sierra Papa Oscar Oscar Kilo Yankee Five Mike Echo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment