17
4
Write a program that takes in a string and spells that word out using the NATO Phonetic Alphabet.
The mapping is as follows:
'A' -> 'Alfa'
'B' -> 'Bravo'
'C' -> 'Charlie'
'D' -> 'Delta'
'E' -> 'Echo'
'F' -> 'Foxtrot'
'G' -> 'Golf'
'H' -> 'Hotel'
'I' -> 'India'
'J' -> 'Juliett'
'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' -> 'Xray'
'Y' -> 'Yankee'
'Z' -> 'Zulu'
Example:
'Hello World' -> ['Hotel', 'Echo', 'Lima', 'Lima', 'Oscar', 'Whiskey', 'Oscar', 'Romeo', 'Lima', 'Delta']
The input can be any string, but will always be comprised of only letters and spaces. Case is irrelevant in the output, but the input may contain letters in uppercase, lowercase, or both. Spaces should be ignored in the output.
You can output in any reasonable format, but it must be a delimited set of NATO callsigns.
4Welcome to PPCG! This question has already been asked. But it probably would have been closed anyway for several other reasons: 1) Unless there's a good reason to do so, asking to answer in a specific way (a function) in a specific language is usually frowned upon. 2) Challenges must be self-contained: you should explain what the NATO phonetic alphabet exactly is within the body of the question. 3) In its current form, it looks like a homework assignment. If it is, you might find help on Stack Overflow, provided that you include what you've done so far and explain where you're stuck. – Arnauld – 2019-01-04T12:26:26.863
4I'd be in favour of reopening this if the points @Arnauld raised above were addressed as it doesn't have the source restriction or input validation of the linked challenge. – Shaggy – 2019-01-04T12:41:43.180
@JoKing, from the test case, which includes a space, it looks like they're simply stripped. – Shaggy – 2019-01-04T12:54:43.243
1I've edited this to possibly be re-openable, since it doesn't have the restriction on characters. Are all my changes appropriate? Especially check the input restrictions. – Rɪᴋᴇʀ – 2019-01-04T16:59:34.383
1@Riker, personally, I'd say ditch the
-
inX-ray
and require the output be in title case. – Shaggy – 2019-01-04T17:07:34.903I agree with @Shaggy about ditching the
-
inX-ray
. Whether the output must be titlecase or not I personally don't mind either. – Kevin Cruijssen – 2019-01-04T18:35:27.947@Shaggy I'll leave that up to OP. I had the - in since I copied that from a list of NATO callsigns and I haven't voted to reopen yet. OP can decide the rest. – Rɪᴋᴇʀ – 2019-01-04T19:05:47.977
10This is the ICAO alphabet; the NATO alphabet uses
Alpha
andJuliet
instead. – Neil – 2019-01-05T11:01:03.4071Can we optionally have the
-
in X-ray? – Οurous – 2019-01-05T19:57:59.1632
Whisky
in the example is not equals toWhiskey
in the mapping. – mazzy – 2019-01-27T09:44:12.330