8
Here's the phonetic alphabet:
Alfa
Bravo
Charlie
Delta
Echo
Foxtrot
Golf
Hotel
India
Juliett
Kilo
Lima
Mike
November
Oscar
Papa
Quebec
Romeo
Sierra
Tango
Uniform
Victor
Whiskey
X-ray
Yankee
Zulu
In the fewest bytes possible:
- Input will be these words in a random order, with the first letters removed.
- Your goal is to arrange the words back to their original order using only the letters you now have. In other words: work out how '[A]lfa' comes before '[B]ravo', and so on. Your code must not refer the original list, index keys, etc.
- Restore the original first letters of each word.
Rules
- The hyphen in X-ray is probably evil, but needs to stay, for I am also evil.
- The result can be a string (comma or newline separated, for example), or an array.
- The spellings and letter cases are non-negotiable.
- No need to show example output in answers.
@LevelRiverSt The sorting is very different without the first character though – fəˈnɛtɪk – 2017-04-11T21:43:51.723
@fəˈnɛtɪk tagging each word fragment with its first letter is arguably a method of sorting. I think sparklepony's proposal is within the OP's intent. Really the OP should answer this, but I would be inclined to closevote again due to nonobservable requirements if the OP said no. It gets messy (what if you use a loop to fish them out one by one, add a letter and print - then you're doing both together. )I'm with Martin's meta OP in cases like this. (and the post he referenced with 19 upvotes and 0 downvotes) – Level River St – 2017-04-11T22:14:57.617
If anyone feels this might be useful, a string which has uniquely identified each of the input words from the start of the string is "l,r,ha,e,c,ox,ol,ot,nd,uli,il,im,ik,ov,s,ap,ue,o,ie,ang,n,i,h,-,a,u" – fəˈnɛtɪk – 2017-04-11T22:23:59.437
1I'm not sure I understand what the output is intended to be. Is it simply the exact phonetic text (or line array) kolmogorov complexity style, except you have a mangled version as input? – xnor – 2017-04-11T22:55:26.700
@xnor You are supposed to return an array of the exact phonetic text by performing operations on the input I think. – fəˈnɛtɪk – 2017-04-11T22:56:29.830
@fəˈnɛtɪk But what does "performing operations on the input" mean? Could one just disregard the input and output the fixed text? I don't expect it to be competitive, but am not clear if it's allowed. – xnor – 2017-04-11T22:58:16.093
3@xnor It might work better then if you are given a random selection of the phonetic alphabet shuffled then you need to return it in order, in which case the fixed text would not be a valid output. – fəˈnɛtɪk – 2017-04-11T22:59:24.643
Two questions: 1. Does start with the words in a random order mean we'll receive them as input? That's what I inferred from the comments. 2. By text variable, do you mean string? – Dennis – 2017-04-12T16:05:16.947