30
\$\begingroup\$

A big part of radio communication is the NATO Phonetic Alphabet, which encodes letters as words to make them easier to understand over comms. Your job, if you wish to accept it, is to print them one by one.

You must print this exact string to stdout:

A: Alfa
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: Xray
Y: Yankee
Z: Zulu

Rules:

  • Your program takes no input
  • Standard loopholes are Disallowed.
  • If there are any builtins in your language that turn letters to their NATO equivelants, you may not use them (I'm looking at you Mathematica).
  • You may have trailing spaces and one trailing newline.
\$\endgroup\$
15
  • 1
    \$\begingroup\$ Related. \$\endgroup\$ Mar 7, 2017 at 8:53
  • 4
    \$\begingroup\$ I'm closing this as a dupe because it doesn't have any exploitable structure that would allow custom compression schemes to perform better than built-in compression, and the target challenge is our de facto standard challenge for built-in compression. \$\endgroup\$
    – user45941
    Mar 7, 2017 at 10:06
  • 1
    \$\begingroup\$ Closely related. If anything I'd call it a dupe of this one, but it allowed people to choose their own words which actually made compression a lot more possible. \$\endgroup\$ Mar 7, 2017 at 10:31
  • 3
    \$\begingroup\$ shouldn't the first one be A: Alpha ? \$\endgroup\$
    – SeanC
    Mar 7, 2017 at 15:13
  • 3
    \$\begingroup\$ @SeanC: According to wikipedia (see link in question), no. That´s ATIS, not NATO. But then, it should be Juliett, not Juliet and X-ray instead of Xray. \$\endgroup\$
    – Titus
    Mar 7, 2017 at 15:27

47 Answers 47

1
2
1
\$\begingroup\$

Bubblegum, 182 bytes

00000000: 05c1 4792 e330 1004 c07b bda2 de51 3779  ..G..0...{...Q7y
00000010: efbd 6e10 b7b5 4210 644f 8026 46bf 9fcc  ..n...B.dO.&F...
00000020: 8138 48ef 80a1 38cc a177 8cc4 d127 e414  .8H...8..w...'..
00000030: 0d63 716c a90d 9888 93e2 e398 8a53 ff6d  .cql.........S.m
00000040: b3b7 9889 334f 6fcc c5b9 b796 b010 17f5  ....3Oo.........
00000050: bf18 b014 975d 8ad6 6225 ae62 72ac c575  .....]..b%.br..u
00000060: ac02 36e2 2696 86ad b8f5 deaa 9765 ecc4  ..6.&........e..
00000070: 5d53 848c bdb8 0f3f 0107 f1d0 d9cb 0a1c  ]S.....?........
00000080: c5a3 57e6 3889 a768 3907 9cc5 73a8 ff3b  ..W.8..h9...s..;
00000090: 2ee2 a58e 6fcf 15ae e235 16ad 67dc c4db  ....o....5..g...
000000a0: 2736 a57d 7117 ef39 7cf1 101f a12e cdf0  '6.}q..9|.......
000000b0: 149f 5dea fe00                           ..]...

Just Zopfli'd the target string for 100 000 iterations.

\$\endgroup\$
1
\$\begingroup\$

C#, 257 242 bytes

Thanks to Kevin Cruijssen for saving 15 bytes!

class P{static void Main(){var c='A';foreach(var t in "lfa ravo harlie elta cho oxtrot olf otel ndia uliet ilo ima ike ovember scar apa uebec omeo ierra ango niform ictor hiskey ray ankee ulu".Split())System.Console.WriteLine(c+": "+c+++t);}}

Full program which prints the required text, with one trailing newline.

Ungolfed:

class P
{
    static void Main()
    {
        var c='A';
        foreach(var t in "lfa ravo harlie elta cho oxtrot olf otel ndia uliet ilo ima ike ovember scar apa uebec omeo ierra ango niform ictor hiskey ray ankee ulu".Split())
            System.Console.WriteLine(c+": "+c+++t);
    }
}
\$\endgroup\$
4
  • 1
    \$\begingroup\$ This is actually 17 bytes longer than the output... :P \$\endgroup\$ Mar 7, 2017 at 10:06
  • 1
    \$\begingroup\$ @StewieGriffin: It's a full program, and C# didn't win awards for being minimalistic :P \$\endgroup\$
    – adrianmp
    Mar 7, 2017 at 10:18
  • 2
    \$\begingroup\$ I know, it was just an observation :) \$\endgroup\$ Mar 7, 2017 at 10:32
  • 4
    \$\begingroup\$ You can golf it to 242 bytes like this. \$\endgroup\$ Mar 7, 2017 at 12:59
1
\$\begingroup\$

Chipmunk BASIC, 191 characters

(Inspired by anonymous2's QBasic solution. Was just too impatient to see a data based variant, so tried it myself.)

data lfa,ravo,harlie,elta,cho,oxtrot,olf,otel,ndia,uliet,ilo,ima,ike,ovember,scar,apa,uebec,omeo,ierra,ango,niform,ictor,hiskey,ray,ankee,ulu
for i=65to 90
read w$
?chr$(i)": "chr$(i)w$
next

Sample run:

Chipmunk BASIC v3.5.8b9
>load "nato.bas"
>run
A: Alfa
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: Xray
Y: Yankee
Z: Zulu
\$\endgroup\$
1
\$\begingroup\$

Common Lisp, 219 bytes

(dolist(c'(alfa bravo charlie delta echo foxtrot golf hotel india juliet kilo lima mike november oscar papa quebec romeo sierra tango uniform victor whiskey xray yankee zulu))(format t"~C: ~:(~A~)~%"(char(string c)0)c))

Ungolfed

(dolist (c '(alfa bravo charlie delta echo foxtrot golf hotel india juliet kilo lima mike november oscar papa quebec romeo sierra tango uniform victor whiskey xray yankee zulu)) 
  (format t "~C: ~:(~A~)~%" (char (string c) 0) c))

Explaination:

dolist is effectively the CL equivalent of python's for _ in _ loop.

The words themselves are stored as lisp symbols, which are upcased after parsing by default.

format actually handles printing out to screen. The heavily lifting is in the format control string: "~C: ~:(~A~)~%".

~C takes a char and just prints it, ~A does the same with an arbitrary lisp object. ~:( and ~) are 'case control' directives, which upcase the first letter of any word printed between them.

(char (string c) 0) Gets the string for the symbol c and pulls the first char out of it.

\$\endgroup\$
1
\$\begingroup\$

Japt, 131 bytes

130 bytes +1 for the -R flag.

;B¬®+": "+`AlfaBŸvoC•r¦eDeltaE®oFoxÉ•GolfHÇUI˜iaJªietKiloL‹aMikeNovem¼rOs¯rPapaQue¼cRo´oSi€ŸTÂ
UnifŽmVÅ¡rW–skeyXŸyY„keeZªu`fZ+"%a+

Try it online!

Explanation

;B¨+": "+`{compressed string}`fZ+"%a+
;B                                     // Alphabet shortcut (ABC...XYZ)
  ¬                                    // Splits the Alphabet, by char, into new lines
   ®                                   // Shortcut for mZ{Z, which maps each item Z to the following:
    +": "+                             //   (Implicit) Z + ": " +
                               fZ+"%a+ //   matches of Z followed by lowercase letters, in
          `{compressed string}`        //   the compressed string "Alfa...Zulu". Backticks are used to decompress the string

The -Rflag is used to seperate each item by newlines.

Japt uses the shoco library for string compression.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Nice one! This reminds me of the original version of your answer on Create an Alphabet Song, unfortunately we can't use the same tricks here that we did there. \$\endgroup\$ Mar 8, 2017 at 18:24
1
\$\begingroup\$

Groovy, 191 bytes

Really nothing fancy, but it's Friday and I wanted to go golfing for the first time.

char c=65;"lfa ravo harlie elta cho oxtrot olf otel ndia uliet ilo ima ike ovember scar apa uebec omeo ierra ango niform ictor hiskey ray ankee ulu".split().any{println("${c}: ${c++}"+it)}​

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to the site! \$\endgroup\$
    – DJMcMayhem
    Mar 10, 2017 at 20:06
1
\$\begingroup\$

8086 machine code, 187 bytes

00000000  be 4c 01 31 c9 53 89 e5  68 0a 24 8a 8f 32 01 29  |.L.1.S..h.$..2.)|
00000010  cc 89 e7 f3 a4 83 c3 41  b7 20 86 fb 53 b3 3a 86  |.......A. ..S.:.|
00000020  fb 53 89 e2 b4 09 cd 21  89 ec 5b 43 83 fb 1a 75  |.S.....!..[C...u|
00000030  d4 c3 03 04 06 04 03 06  03 04 04 05 03 03 03 07  |................|
00000040  04 03 05 04 05 04 06 05  06 03 05 03 6c 66 61 72  |............lfar|
00000050  61 76 6f 68 61 72 6c 69  65 65 6c 74 61 63 68 6f  |avoharlieeltacho|
00000060  6f 78 74 72 6f 74 6f 6c  66 6f 74 65 6c 6e 64 69  |oxtrotolfotelndi|
00000070  61 75 6c 69 65 74 69 6c  6f 69 6d 61 69 6b 65 6f  |aulietiloimaikeo|
00000080  76 65 6d 62 65 72 73 63  61 72 61 70 61 75 65 62  |vemberscarapaueb|
00000090  65 63 6f 6d 65 6f 69 65  72 72 61 61 6e 67 6f 6e  |ecomeoierraangon|
000000a0  69 66 6f 72 6d 69 63 74  6f 72 68 69 73 6b 65 79  |iformictorhiskey|
000000b0  72 61 79 61 6e 6b 65 65  75 6c 75                 |rayankeeulu|
000000bb

Equivalent assembly code:

org 0x100
use16
    mov si, nato
    xor cx, cx
@@: push bx
    mov bp, sp
    push 0x240a
    mov cl, [len+bx]
    sub sp, cx
    mov di, sp
    rep movsb
    add bx, 'A'
    mov bh, ' '
    xchg bh, bl
    push bx
    mov bl, ':' 
    xchg bh, bl
    push bx
    mov dx, sp
    mov ah, 0x09
    int 0x21
    mov sp, bp
    pop bx
    inc bx
    cmp bx, 26
    jne @b
    ret

len db 3,4,6,4,3,6,3,4,4,5,3,3,3,7,4,3,5,4,5,4,6,5,6,3,5,3
nato db "lfaravoharlieeltachooxtrotolfotelndiaulietiloimaikeovemberscarapauebecomeoierraangoniformictorhiskeyrayankeeulu"
\$\endgroup\$
0
\$\begingroup\$

Batch, 216 bytes

@for %%w in (Alfa Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliet Kilo Lima Mike November Oscar Papa Quebec Romeo Sierra Tango Uniform Victor Whiskey Xray Yankee Zulu)do @set l=%%w&call echo %%l:~,1%%: %%l%%
\$\endgroup\$
0
\$\begingroup\$

C (gcc), 393 bytes

#define p printf
long a[]={0x16C,0xf7f13f,0x59c3f18,0x15fc5,0xF83,0x5f0f3f5f9f0f,0x6c0f,0xC55f0f,0x194e,0x5f59c6f,0xfc9,0x1d9,0x5b9,0x3f52d57f0f,0x3f134f,0x11f1,0x35256f,0xf5d0f,0x13f3f59,0xf7e1,0xd3f0f69e,0x3f0f5f39,0xafb4f98,0xaf13f,0x55be1,0x6fc6f};i,j;d(long n){for(;n;n/=16){if(j=n&15){if(j>14)n/=16,j+=n&15;p("%c",96+j);}else n=0;}}r(){for(i=0;i<26;p("\n"))p("%c: %1$c",i+65),d(a[i++]);}

I thought it would be shorter than it is. I was wrong..

Each long int in long a[] represents a word containing the remaining letters of the required mnemonic once the first letter has been removed. Letters are encoded right to left whereby if the 4 lower bits are 0xF then it adds it to the next 4 bits and shifts it all down appropriately, repeating until the variable is empty.

Try it online!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ 283: main(){puts("A: Alfa\nB: Bravo\nC: Charlie\nD: Delta\nE: Echo\nF: Foxtrot\nG: Golf\nH: Hotel\nI: India\nJ: Juliet\nK: Kilo\nL: Lima\nM: Mike\nN: November\nO: Oscar\nP: Papa\nQ: Quebec\nR: Romeo\nS: Sierra\nT: Tango\nU: Uniform\nV: Victor\nW: Whiskey\nX: Xray\nY: Yankee\nZ: Zulu");} \$\endgroup\$
    – jayjay
    Mar 7, 2017 at 18:09
  • \$\begingroup\$ @jayjay kind of takes the fun out of it, doesn't it? \$\endgroup\$
    – Ahemone
    Mar 7, 2017 at 22:53
  • \$\begingroup\$ I will give you that! Yours is much more interesting. :) \$\endgroup\$
    – jayjay
    Mar 8, 2017 at 10:00
  • \$\begingroup\$ 352 bytes \$\endgroup\$
    – ceilingcat
    Nov 13, 2019 at 2:46
0
\$\begingroup\$

CJam, 160 158 bytes

'A"lfa ravo harlie elta cho oxtrot olf otel ndia uliet ilo ima ike ovember scar apa uebec omeo ierra ango niform ictor hiskey ray ankee ulu"S/{_": "\_)QN@}fQ;

Try it online!

Explanation

'A                         Push the character 'A'
  "..."S/                  Split huge string on spaces
         {           }fQ   For each word Q:
          _                  Duplicate top of stack (the character)
           ": "\             Push ": ", swap top stack elements; results in "A: A"
                _)           Duplicate the char on top and increment it (the next letter)
                  QN         Push Q and a newline
                    @        Bring the third-top element of the stack to the top
                              (brings the next character on top for the next iteration)
                        ;  Delete the top stack element, since at the end there will be a
                            '[' character on top
\$\endgroup\$
0
\$\begingroup\$

IBM/Lotus Notes Formula - 195 Bytes

L:=@Explode("Alfa Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliet Kilo Lima Mike November Oscar Papa Quebec Romeo Sierra Tango Uniform Victor Whiskey Xray Yankee Zulu");@Left(L;1)+": "+L

Formula will by default apply a given function to each value in a list in turn so no for loop needed. @Explode (equivalent to split in other more sensible languages) defaults to " ","," or ";" if no separator is supplied in the function call. As an aside, @Implode also equates to join. I guess formula is a bit too verbose and was not really made for golfing but some of the list operators are still cool and work as well as they did 20 odd years ago.

No TIO available for LN so screenshot shown below:

enter image description here

\$\endgroup\$
0
\$\begingroup\$

C, 199 bytes

f(){char*s=" AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu";while(*++s){printf("\n%c: %c"+*s/96*5,*s,*s);}}
\$\endgroup\$
4
  • \$\begingroup\$ I've been banging my head on this: "\n%c: %c"+*s/96*5 and I can't understand why it works. Care to elaborate? Also isn't it possible to remove the new line in the front? With it the solution is not correct. \$\endgroup\$ Mar 8, 2017 at 21:32
  • \$\begingroup\$ BTW, your solution could be rewritten with a for loop and the printf could be changed to printf("\n%c: %1$c"+*s/96*5,*s) and thus save 4 bytes. Though it's still not correct. \$\endgroup\$ Mar 9, 2017 at 12:26
  • \$\begingroup\$ And please, explain how this works: "\n%c: %c"+*s/96*5. \$\endgroup\$ Mar 9, 2017 at 12:26
  • 1
    \$\begingroup\$ @ItayGrudev I’ll look into a fix later. "abc" is a pointer to the start of a constant string, and "abc"+2 adds 2 to that pointer, giving you a pointer to "c", for example. \$\endgroup\$
    – Lynn
    Mar 9, 2017 at 13:14
0
\$\begingroup\$

Perl, 188 bytes

$n=64;$x="LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu";while($x=~/.[a-z]*/g){$_=chr(++$n)."\l$&
";s/(.).*/$1: $&/;print}

Ungolfed version:

$x="LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu";
$n=64;
while ($x =~ /([A-Z][a-z]*)/g) {
    $y = chr(++$n) . "\l$1\n";
    $y =~ s/(.)(.*)/$1: $1$2/;
    print $y;
}

\$\endgroup\$
0
\$\begingroup\$

Perl, 185 164 163 bytes

Saved 11 12 bytes with help from @manatwork

print$a=chr$i+++65,": $a\l$_\n"for split/(?=[A-Z])/,LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu
\$\endgroup\$
2
  • 1
    \$\begingroup\$ May I suggest to reorder the used instructions/functions? print$a=chr$i+++65,": $a\l$_\n"for split/(?=[A-Z])/,LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu \$\endgroup\$
    – manatwork
    Mar 8, 2017 at 12:51
  • \$\begingroup\$ Nice! thanks, I'll update my code \$\endgroup\$
    – CraigR8806
    Mar 8, 2017 at 12:57
0
\$\begingroup\$

REXX, 192 bytes

@='lpha ravo harlie elta cho oxtrot olf otel ndia uliet ilo ima ike ovember scar apa uebec omeo ierra ango niform ictor hiskey ray ankee ulu'
do #=1 to 26
  c=d2c(#+64)
  say c':' c||word(@,#)
  end
\$\endgroup\$
0
\$\begingroup\$

Java, 300 275 bytes

interface x{static void main(String[]a){for(int i=0;i<26;i++) System.out.println(String.format("%c: %c%s",'A'+i,'A'+i,"lfa_ravo_harlie_elta_cho_oxtrot_olf_otel_ndia_uliet_ilo_ima_ike_ovember_scar_apa_uebec_omeo_ierra_ango_niform_ictor_hiskey_ray_ankee_ulu".split("_")[i]));}}

Ungolfed version with comments:

interface x {
    static void main(String[] a) {
        for (int i = 0; i < 26; i++)            // For all characters in alphabet
            System.out.println(                 // Print string
                    String.format("%c: %c%s",   // Formatted string(similar to printf)
                            'A'+i,              // Letter
                            'A'+i,              // Letter
                            "lfa_ravo_harlie_elta_cho_oxtrot_olf_otel_ndia_uliet_ilo_ima_ike_ovember_scar_apa_uebec_omeo_ierra_ango_niform_ictor_hiskey_ray_ankee_ulu".split("_")[i])); // Absurdly long string containing all words without first letters, divided into an array by _
    }
}
\$\endgroup\$
0
\$\begingroup\$

q, 167 bytes

Link to interpreter download

-1@.Q.A,'": ",/:.Q.A,'" "vs"lpha ravo harlie elta cho oxtrot olf otel ndia uliet ilo ima ike ovember scar apa uebec omeo ierra ango niform ictor hiskey ray ankee ulu";
\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.