Charlie, Oscar, Delta, Echo

30

8

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.

sagiksp

Posted 2017-03-07T08:31:11.370

Reputation: 1 249

1Related. – Martin Ender – 2017-03-07T08:53:50.730

Yea I saw that one but thought this was different enough @MartinEnder – sagiksp – 2017-03-07T09:04:34.930

@sagiksp No one said it wasn't. :) – Martin Ender – 2017-03-07T09:08:23.037

@KritixiLithos How is this a duplicate? It's completely different and the only similarity is that they are both kolmogorov complexity. – sagiksp – 2017-03-07T10:06:10.913

4I'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. – Mego – 2017-03-07T10:06:11.067

@Mego Is it? The rick roll has so much structure that custom compression probably makes a lot more sense than built-in compression. – Martin Ender – 2017-03-07T10:29:09.203

1Closely 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. – Martin Ender – 2017-03-07T10:31:48.990

May I have a leading newline? – Titus – 2017-03-07T14:04:36.890

3shouldn't the first one be A: Alpha ? – SeanC – 2017-03-07T15:13:44.610

3@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. – Titus – 2017-03-07T15:27:01.533

1@Titus I removed the dash from xray on purpose because I thought that would complicate any compression trying to decode it, I have no idea how juliet lost a t and for your other question, yes, but just one. – sagiksp – 2017-03-07T19:05:07.160

I found a kind of related joke language. My favorite example usage is Input: = pants nopants Output: 100%, nopants.

– mbomb007 – 2017-03-07T19:43:06.650

Didn't know about that one :D @mbomb007 – sagiksp – 2017-03-07T20:30:12.600

Brings back memories. The answer I had to give in military inspection was always "November-oscar-sierra-romeo-hotel-echo-papa-sierra-romeo-echo-delta-november-alpha-romeo, sir." – Glenn Randers-Pehrson – 2017-03-07T21:15:16.613

See also a related problem with solutions public: http://golf.shinh.org/p.rb?International+Radiotelephony+Spelling+Alphabet

– b_jonas – 2017-03-09T12:45:04.207

Answers

18

Python 2, 189 186 bytes

i=65
for w 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():print'%c: %c'%(i,i)+w;i+=1

Try it online!


Previous: (this was cool, but I realised the simpler version could be made shorter by a byte)

w=''
i=65
for c in"lfAravOharliEeltAchOoxtroTolFoteLndiAulieTilOimAikEovembeRscaRapAuebeComeOierrAangOniforMictoRhiskeYraYankeEulU":
 w+=c.lower()
 if'_'>c:print'%c: %c'%(i,i)+w;w='';i+=1

Jonathan Allan

Posted 2017-03-07T08:31:11.370

Reputation: 67 804

12

Jelly, 76 bytes

“ṭṡl°ẠkWßġȮRẎ+wḋñȥạġ¢ƊḌ¬kạẠ¦WṡỊƒK⁹ç}⁶hm}Kñ£ɦ/lṇẊɠƓ}pƤ°⁸Ụ.g⁹Ġh9ṁ{f»ḲØAżj€⁾: Y

Try it online!

How?

Pretty much just dictionary values and compression. The code between and » is just a compressed value that will form the string "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" by looking up all the words (with single space prefixes, except for "Alfa") in Jelly's dictionary (except for " Xray" which is not in the dictionary, so the direct string value " X" and the dictionary entry "ray" are used instead).

The rest of the code does the rest:

“...»ḲØAżj€⁾: Y - Main link: no arguments
“...»           - the string described above (really a list of characters)
     Ḳ          - split at spaces
      ØA        - alphabet yield - ['A','B','C', ...,'X','Y','Z']
        ż       - zip - makes a list of lists [['A'],['A','l','f','a']],[['B'],['B','r','a','v','o']], ...]
         j€     - join each with
           ⁾:   - the string ": "
              Y - join with line feeds
                - implicit print

Jonathan Allan

Posted 2017-03-07T08:31:11.370

Reputation: 67 804

(NOTE: I never programmed in Jelly.) When I see your code I'm wondering two things: 1. You currently loop over the alphabet and join them with the words. Is it possible in Jelly to get the first character of a string, so you loop over the words instead of the alphabet, and join them with first_letter_of_word + ": " + word? And 2. You retrieve all words including spaces and then split by space. Is it possible to inclusive-split by the leading capital letters? No idea if these spaces even give extra bytes in their compressed form or not, and if they can be reduced with my description at 2. – Kevin Cruijssen – 2017-03-07T09:42:07.000

1@KevinCruijssen (1) yes it's possible to use the first letter of each word, however it wont be as short since the alphabet yield is a two-byte atom. (2) yes it's possible to split on capital letters, but surprisingly the compression of the string with no spaces is actually longer (many words with leading spaces are actually in the dictionary, as are all of these with capitalisation). – Jonathan Allan – 2017-03-07T09:48:52.603

2The dictionary doesn't contain leading spaces. However, when decompressing multiple words in a row, the default is to separate them by spaces; the first word won't have a leading space, but all following words will. – Dennis – 2017-03-07T19:36:34.160

11

Retina, 156 bytes

Byte count assumes ISO 8859-1 encoding.


AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu
[A-Z]
¶$&: $&
G`.

Try it online!

Martin Ender

Posted 2017-03-07T08:31:11.370

Reputation: 184 808

11

05AB1E, 102 98 bytes

Saved 4 bytes thanks to Erik the Outgolfer

”AlfaІvo¼¯¤œ®È¨›trotŠˆƒ‹Š™ÈŸt Kilo´àma—……ÍЗŽêpa¼°«Äoµ†Çâgo¸šÉµ Whiskey Xrayµ‹nkeeâ¸lu”#vy¬„: «ì,

Try it online!

Explanation

Uses dictionary compression for the words in 05AB1E's dictionary.
Uses partial dictionary compression whenever possible for other words.
Plain-text words where neither is possible.

#          # split on spaces
 v         # for each word
  y        # push the word
   ¬       # get the first letter of the word
    „:     # push the string ": "
       «   # append this to the letter
        ì  # prepend the result to the word
         , # print with newline

Emigna

Posted 2017-03-07T08:31:11.370

Reputation: 50 798

2Get it down to 98 using this compressed string instead: ”AlfaІvo¼¯¤œ®È¨›trotŠˆƒ‹Š™ÈŸt Kilo´àma—……ÍЗŽêpa¼°«Äoµ†Çâgo¸šÉµ Whiskey Xrayµ‹nkeeâ¸lu”. – Erik the Outgolfer – 2017-03-07T12:56:50.263

@EriktheOutgolfer: Thanks! I was sure I looked for pa and li in the dictionary but I must have missed them. I didn't consider ya and zu as words though :) – Emigna – 2017-03-07T13:34:43.040

6

Java 7, 242 225 222 217 bytes

void d(){char c=65;for(String s:"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".split(" "))System.out.println(c+": "+c+++s);}

Explanation:

void d(){                          // Method
  char c = 65;                     //  Starting character 'A'
  for(String s : "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"
      .split(" "))                 //  Loop over the word-parts
    System.out.println(            //   Print line with:
      c                            //    The current character
      + ": "                       //    + ": "
      + c++ + s                    //    + the current character + word-part (and raise the character afterwards)
    );                             //   End of print line
                                   //  End of loop (implicit / single-line body)
}                                  // End of method

Test code:

Try it here.

class M{
  static void d(){char c=65;for(String s:"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".split(" "))System.out.println(c+": "+c+++s);}

  public static void main(String[] a){
    d();
  }
}

Kevin Cruijssen

Posted 2017-03-07T08:31:11.370

Reputation: 67 575

Should work with Java 5 and all subsequent versions. – Holger – 2017-03-07T14:30:47.720

6

Ruby, 169 characters

(Heavily based on Jonathan Allan's Python 2 solution. If you like the idea, please upvote the original answer.)

i=?@
"LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu".scan(/.[a-z]+/){|w|puts i.succ!+": "+i+w.downcase}

Sample run:

bash-4.3$ ruby -e 'i=?@;"LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu".scan(/.[a-z]+/){|w|puts i.succ!+": "+i+w.downcase}' | head
A: Alfa
B: Bravo
C: Charlie
D: Delta
E: Echo
F: Foxtrot
G: Golf
H: Hotel
I: India
J: Juliet

manatwork

Posted 2017-03-07T08:31:11.370

Reputation: 17 865

5

PHP, 202 227 196 187 bytes

Thanks to Dewi Morgan for saving 9 bytes

echo preg_replace('/([A-Z])[a-z]+/',"$1: $0\n",AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu);

https://repl.it/GMkH/1


Older versions

Thanks to manatwork and insertusernamehere for saving 31 bytes!

foreach(preg_split('/\B(?=[A-Z])/',AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu)as$k)echo"$k[0]: $k\n";

https://eval.in/749541

Thanks to insertusernamehere for noticing the output was wrong with the previous version.

$a=preg_split('/(?=[A-Z])/',AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu,-1,PREG_SPLIT_NO_EMPTY);foreach($a as $k)echo "$k[0]: $k\n";

https://repl.it/GKS8/3

$a=preg_split('/(?=[A-Z])/',AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu);foreach($a as $k)echo"$k[0]: $k\n";

https://repl.it/GKS8/2

ʰᵈˑ

Posted 2017-03-07T08:31:11.370

Reputation: 1 426

Why variable $a? Just move the entire preg_split() call in foreach's parameter. Then none of the spaces around as will be necessary anymore. – manatwork – 2017-03-07T09:06:29.757

Instead of constant PREG_SPLIT_NO_EMPTY, better use its value: 1. But personally I would tweak the regular expression instead: /\B(?=[A-Z])/. – manatwork – 2017-03-07T09:22:01.843

1Thanks @insertusernamehere i'll make that edit now :D Still getting used to codegolfing – ʰᵈˑ – 2017-03-07T09:34:38.573

That would be one byte shorter with a plain array instead of the preg_split. – Titus – 2017-03-07T14:21:07.803

Errm no it wouldn´t ... Echo needs quotes. – Titus – 2017-03-07T19:17:52.560

Are methods like gzinflate(), etc forbidden by the standard loopholes? Feels like you could save a dozen bytes or so by compressing the string. – Dewi Morgan – 2017-03-07T23:07:22.670

Also consider a regex over LfaRavoHarlie - the first letters can be autogen'd by a loop, saving 26 bytes, but possibly at too high a cost. – Dewi Morgan – 2017-03-07T23:40:42.607

110 characters shorter: echo preg_replace('/([A-Z])[a-z]+/',"$1 = $0\n",Alfa...Zulu); – Dewi Morgan – 2017-03-08T16:46:03.643

@DewiMorgan nice one, thanks! – ʰᵈˑ – 2017-03-08T17:05:34.467

Then how's about a 178ish? :D $z=A;foreach([lfa,ravo,...,ulu]as$k)echo"$z: $z$k\n";$z++; – Dewi Morgan – 2017-03-08T17:38:28.017

Oops, I'd need the curlies on that foreach, adding 2 chars, so it's just as efficient to do $z=A;foreach([lfa,ravo,...,ulu]as$k)echo"$z: ".$z++."$k\n"; – Dewi Morgan – 2017-03-08T18:01:04.590

You can take it down into the 160s if you're willing to do something like $z=A;foreach(explode(X,gzinflate('BINARY_GARBAGE'))as$k)echo"$z: ".$z++."$k\n"; where BINARY_GARBAGE is the output of gzdeflate('lfaXravoXharlieXeltaXchoXoxtrotXolfXotelXndiaXulietXiloXimaXikeXovemberXscarXapaXuebecXomeoXierraXangoXniformXictorXhiskeyXrayXankeeXulu') You can even knock a further couple chars off by replacing explode() with split(), but then you drop compatibility with PHP7. – Dewi Morgan – 2017-03-08T18:12:31.123

I think technically you should add <? at the beginning, though, for character count for PHP. Alternatively, as with Titus' solution below, find something that can use <?= to save on characters wasted by echo... – Dewi Morgan – 2017-03-08T18:35:19.223

@DewiMorgan, you mean exactly like my solution? I posted that a couple of hours before your comment, by the way.

– aross – 2017-03-17T09:08:36.427

@aross Yep, looks like many people beat me to my realizations! I didn't realize until I was several comments in that this was not the only PHP post, though, so for a moment there, I thought I was clever :) Your post, at 162b, is impressive... though I confess to having no clue how it works. – Dewi Morgan – 2017-03-19T01:23:16.743

@DewiMorgan, thanks. I actually changed my implementation to that foreach, but before that I used the same approach as your comment. New method iterates over the chars in the string (by string index), checks whether it's an uppercase char (less than a), then prints the char lowercased by setting a bit in the char with binary OR. If it was an uppercase char, prefixes that char with "\nA: A" – aross – 2017-03-20T08:50:56.637

5

Octave, 215 210 209 bytes

Saved 5 bytes thanks to Luis Mendo. I saved 4 bytes thanks to Luis Mendo, but changing the approach help me save one more

fprintf('%s: %s%s\n',[k=num2cell(65:90);k;regexp('lfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu','[A-Z]','split')]{:})

Try it online!

If I got rid of the spaces, I'd save 25 bytes, but then I'd have to use a regex. The regex itself would cost quite a few bytes, and it would also remove the capital letter of all words, leaving me with the words lfa, ravo etc. I would therefore have to concatenate the new strings with the leading characters. All this costs bytes.

Old explanation:

fprintf('%s: %s\n',      % Print a string with the format "str: str\n"
num2cell(65:90)          % Create a cell array with the numbers 65 - 90, one in each cell
strsplit('Alfa ...       % Split the string on the default delimiter: space
[num2cell();strsplit()]  % Concatenate cell arrays, leaving us with
                         % {'A',    'B'
                         %  'Alfa', 'Bravo'}
[...]{:}                 % Convert the cell array to a comma-delimited vector
                         % 'A', 'Alfa', 'B', 'Bravo' ...

Stewie Griffin

Posted 2017-03-07T08:31:11.370

Reputation: 43 471

Thanks! This was a bit messier!, and three bytes longer...

– Stewie Griffin – 2017-03-07T10:02:15.570

Ah, yes, 'split' would be longer here – Luis Mendo – 2017-03-07T13:15:55.267

'split' was shorter: 209 :) – Stewie Griffin – 2017-03-07T14:23:49.677

I see! Well done! – Luis Mendo – 2017-03-07T14:56:37.077

You can split on spaces and save 5 more bytes

– Luis Mendo – 2017-03-07T17:24:15.623

... or go back to strsplit?

– Luis Mendo – 2017-03-07T17:26:54.270

Thanks again Luis, but maybe you should post it yourself since it's quite different...? (I do appreciate the tips though, don't misunderstand me)

– Stewie Griffin – 2017-03-07T20:55:03.690

No, it's quite similar to your approach. Post it yourself if you want :-) – Luis Mendo – 2017-03-07T23:01:09.953

4

Brachylog, 178 bytes

"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"ṇ₁{hw": "w?ẉ}ᵐ

Try it online!

Explanation

"…"ṇ₁               Split the string on spaces
     {         }ᵐ   Map on each word:
      hw              Write the first letter
        ": "w         Write ": "
             ?ẉ       Write the word followed by a new line

Fatalize

Posted 2017-03-07T08:31:11.370

Reputation: 32 976

4

C (MinGW, Clang), 218 bytes

Thanks to @gastropner!

i;f(){char s[]="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=64;++i<91;)printf("%c: %c%s\n",i,i,strtok(i^65?0:s,":"));}

Try it online!

C, 259 236 bytes

i;f(){char*s="lfa\0ravo\0harlie\0elta\0cho\0oxtrot\0olf\0otel\0ndia\0uliet\0ilo\0ima\0ike\0ovember\0scar\0apa\0uebec\0omeo\0ierra\0ango\0niform\0ictor\0hiskey\0ray\0ankee\0ulu";for(i=64;++i<91;s+=strlen(s)+1)printf("%c: %c%s\n",i,i,s);}

Try it online!

Steadybox

Posted 2017-03-07T08:31:11.370

Reputation: 15 798

How would I compile this? – Itay Grudev – 2017-03-08T02:12:57.950

1

@ItayGrudev, GCC and Clang should both compile that as is. gcc src.c or clang src.c. Here's a sample run with a main function added so the code will actually link and run: http://ideone.com/4Eowlh

– chris – 2017-03-08T17:51:43.083

@chris Then at the expense of 4 bytes, shouldn't f be replaced with main so the code is valid, or am I missing some golfing convention. – Itay Grudev – 2017-03-08T18:36:49.457

2@ItayGrudev, The way I see it, the question only asked for the functionality, not a full, self-contained program. – chris – 2017-03-08T20:03:10.927

1218 with strtok() and some fiddling with the string i;f(){char s[]="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=64;++i<91;)printf("%c: %c%s\n",i,i,strtok(i^65?0:s,":"));} Unclear if it works everywhere: TIO segfaults but works in MinGW at least. Can't see much of a reason why it wouldn't work. – gastropner – 2017-11-23T11:40:24.913

@gastropner Thanks! It works with MinGW on my computer too, and seems to work also on TIO with Clang (but not with gcc or tcc). – Steadybox – 2017-11-23T16:08:08.210

4

PHP, 188 186 180 174 bytes

no trailing spaces, one leading newline

<?=preg_filter("#[A-Z]#","
$0: $0",AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu);

simply replaces all uppercase letters in the compressed string with
<newline><letter><colon><space><letter>

Titus

Posted 2017-03-07T08:31:11.370

Reputation: 13 814

This time competitive ? ;)

– Christoph – 2017-03-07T14:28:50.633

-13 bytes with gzinflate-ing the result of gzdeflate(Alfa...Zulu). – Titus – 2017-03-07T19:07:40.173

Unfortunately, no leading newline is allowed, only a (single) trailing newline – aross – 2017-03-08T13:58:49.373

@aross: see the OP´s comment from yesterday: and for your other question, yes, but just one. – Titus – 2017-03-09T01:22:22.050

4

Python 2, 186 182 bytes

print''.join('\n%s: '%c*('['>c)+c for c in'AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu')

Try it online!

Felipe Nardi Batista

Posted 2017-03-07T08:31:11.370

Reputation: 2 345

2see comments on question: one leading newline is (now) accepted – Titus – 2017-03-07T19:13:45.257

Welcome to PPCG! Nice stuff. – Jonathan Allan – 2017-03-07T20:02:29.523

4

x86 Assembly, 512 bytes

Compiled with NASM and tested with QEMU. To boot you need to put a 2 byte boot signature at the end of the bootsector (510 bytes into the file) so I lost 317 bytes filling the compiled code with zeros. This is my first golf so I have to apologize for any gigantic errors.

[org 7c00h]     ;So NASM can change the labels into memory locations correctly.

cld             ;Tells lodsb to look forward in memory

mov bh, 65      ;Moves the ASCII value of A into the BH register
mov si, NATO    ;Moves the first byte of NATO into the si register
call print      ;Call the 'print' subroutine

jmp $            ;Loops forever

print:
    mov ah, 0eh ;Moves the hex value 0E into the AH register. Tells interrupt 10h that we want subfucntion 0E
    lodsb       ;Load a byte of SI into AL and increments a register (DL i think) that tells it the offset to look at

    cmp al, 3   ;Compares the AL register that now has a byte from our string to ASCII value 3 (Enf Of Text)
    je R        ;If AL == 3 then jump to R

    cmp al, 0   ;Comapre AL to ASCII 0 (NULL)
    je newWord  ;If AL == 0 hump to newWord
    int 10h     ;Execute interrupt 10h Subfunction 0Eh (stored in AH register) which prints character value in AL
    jmp print   ;Jump to print

newWord:
    mov al, 10  ;Move ASCII 10 (New Line) into AL
    int 10h     ;Print character

    mov al, 13  ;Move ASCII 13 (Carriage Return) into AL
    int 10h     ;Print character

    mov al, bh  ;Move BH (which has our starting letter) into AL
    int 10h     ;Print Character

    mov al, 58  ;Move ASCII 58 (:) into AL
    int 10h     ;Print Character

    mov al, 32  ;Move ASCII 32 (Space) into AL
    int 10h     ;Print Character

    mov al, bh  ;Move BH into AL
    int 10h     ;Print Character

    inc bh      ;Increments BH by one (BH++)
    jmp print   ;Jump to print

R:
    ret         ;Returns from a subroutine

;Below defines bytes (db) of our string to print. I used 0 as word seperators and 3 to end the string.
NATO: db 0,"lfa",0,"ravo",0,"harlie",0,"elta",0,"cho",0,"oxtrot",0,"olf",0,"otel",0,"ndia",0,"uliet",0,"ilo",0,"ima",0,"ike",0,"ovember",0,"scar",0,"apa",0,"uebec",0,"omeo",0,"ierra",0,"ango",0,"niform",0,"ictor",0,"hiskey",0,"ray",0,"ankee",0,"ulu",3

times 0200h - 2 - ($ - $$) db 0 ;Zerofill the file with upto 510 bytes (This is where all my bytes are)
dw 0AA55H   ;Write the bootsignature

Output

This is what the above code outputs. As you can see A: Alfa is missing and that is because the prompt is 25 lines tall... Above codes output

To prove I printed A: Alfa I replaced 0,"ulu" with 32,"Z: Zulu" so that Zulu is one on the same line as Yankee. Changed code

I would appreciate it if someone told me if I would be able to subtract the 317 bytes of zerofill from my code so it would be 195 bytes. Also if this is even valid because the output won't fit on the screen.

Alarmed Dino

Posted 2017-03-07T08:31:11.370

Reputation: 41

3

Gema, 168 characters

\A=@subst{?<J>=\?: \$0\\n;AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu}@end

Sample run:

bash-4.3$ gema '\A=@subst{?<J>=\?: \$0\\n;AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu}@end' | head
A: Alfa
B: Bravo
C: Charlie
D: Delta
E: Echo
F: Foxtrot
G: Golf
H: Hotel
I: India
J: Juliet

manatwork

Posted 2017-03-07T08:31:11.370

Reputation: 17 865

3

Bash, 224 205 188 180 bytes

Thanks to Digital Trauma for removing 17 bytes, and manatwork for 8 bytes.

set {A..Z}
for i 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;{ echo $1: $1$i;shift;}

Try it online!

luk3yx

Posted 2017-03-07T08:31:11.370

Reputation: 161

1Some golfing – Digital Trauma – 2017-03-08T22:14:41.227

Indexing array a is too long. set {A..Z};for i in lfa … ulu;{ echo $1: $1$i;shift;} – manatwork – 2017-03-09T12:23:34.820

2

JavaScript ES6, 216 187 184 180 174 bytes

"AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu".replace(/[A-Z]/g,`
$&: $&`).trim()

Saved a byte thanks to Neil. Saved 5 bytes thanks to ETHproductions.

console.log("AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu".replace(/[A-Z]/g,`
$&: $&`).trim());

Japt, 127 bytes

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

Try it online!

Saved 2 bytes thanks to obarakon.

Tom

Posted 2017-03-07T08:31:11.370

Reputation: 3 078

I was wondering how else you could get rid of that leading newline - it would have actually been a byte cheaper than your previous approach to manually prepend A: A to the string. But you can still save another byte by using a literal newline character instead of \n. – Neil – 2017-03-07T10:23:08.207

Nice answers. You can use a literal newline in Japt as well. Also, replace accepts a string for its second argument and replaces any $&s in it with the match, so you can do e.g "\n$&: $&" for both langs instead of using functions. – ETHproductions – 2017-03-07T21:54:03.343

You can change @"\n{X}: {X}"} in Japt to just "\n$&: $&" :-) – ETHproductions – 2017-03-08T15:23:19.043

@ETHproductions Thanks for the help! – Tom – 2017-03-08T15:36:10.383

Nice answer! You can save a couple bytes by dropping the " x and inserting a -x flag into the input. Note that the flag adds 1 byte to the total bytes. – Oliver – 2017-03-09T00:16:38.207

2

Python 2, 198 bytes

for x 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'.split():print x[0]+': '+x

Try it online!

Not exciting or clever. Just loops through the list and prints the first letter then ': ' then the whole word.

ElPedro

Posted 2017-03-07T08:31:11.370

Reputation: 5 301

2

Lua, 278 260 bytes

Thanks again to Manatwork for saving 18 bytes!

function f(w)print(w.sub(w,0,1)..": "..w)end
f"Alfa"f"Bravo"f"Charlie"f"Delta"f"Echo"f"Foxtrot"f"Golf"f"Hotel"f"India"f"Juliet"f"Kilo"f"Lima"f"Mike"f"November"f"Oscar"f"Papa"f"Quebec"f"Romeo"f"Sierra"f"Tango"f"Uniform"f"Victor"f"Whiskey"f"Xray"f"Yankee"f"Zulu"

Try it online


Older versions

a={"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"}
for i=1,26 do print(a[i].sub(a[i],0,1) .. ": " .. a[i]) end

https://repl.it/GK8J

First time doing Lua, do probably can golf more, but thought I'd add it as an answer anyways.

ʰᵈˑ

Posted 2017-03-07T08:31:11.370

Reputation: 1 426

My question may become boring, but again: Why variable a? ;) You can move the entire array declaration inside the for. And the for..in syntax helps to avoid writing those long array indices: http://pastebin.com/rxck79md Weird Lua thing: if you declare a function and call it 26 times “manually” (I mean, not in a loop) is shorter: http://pastebin.com/FMF9GmLJ – manatwork – 2017-03-08T09:04:54.730

¯\_(ツ)_/¯ for the simple reason that I never used Lua before so I was just following the manual to try make it work, aha. Thanks @manatwork for the info, I didn't know about that. – ʰᵈˑ – 2017-03-08T09:08:58.217

2

PowerShell, 187 185 bytes

0..25|%{($a=[char]($_+65))+": $a"+(-split'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')[$_]}

Try it online!

Loops from 0 to 25, each iteration forming $a of the corresponding capital char. Then string-concatenated with : $a (i.e., the colon-space-letter). Then that string is string-concatenated with an string that's formed by indexing into an array created by -splitting the phonetic string on spaces. Each of those 26 strings is left on the pipeline, and an implicit Write-Output happens at program completion, inserting a newline between elements.

Saved two bytes thanks to @Matt.

AdmBorkBork

Posted 2017-03-07T08:31:11.370

Reputation: 41 581

Nice. Removing the first character of each word didn't even occur to me. You can chop off 2 bytes doing this: 0..25|%{($a=[char]($_+65))+": $a"+(-split'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')[$_]} – Matt – 2017-03-08T15:18:24.480

@Matt Oh sure, that makes sense. Thanks! – AdmBorkBork – 2017-03-08T15:29:57.800

2

PHP, 184 bytes 179 bytes 178

<?=preg_filter('/(.)[a-z]+/',"$1: $0
",AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu);

saved a single byte by using preg_filter instead of preg_replace.


Original answer 184 bytes 179 bytes

for($c=A;$s=[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][+$i++];$c++)echo"$c: $c$s
";

uses the fact that its sorted to generate the first char on the fly.

5 bytes saved by @Titus.

Christoph

Posted 2017-03-07T08:31:11.370

Reputation: 1 489

2Golf your original down to 180-1 with for($c=A;$s=[lfa,...,ulu][+$i++];$c++)echo"$c: $c$s\n";. Nice regex though. – Titus – 2017-03-07T14:59:48.667

@Titus I had in mind there must be a better way but switched to preg. Thanks for the tip ! – Christoph – 2017-03-07T15:01:14.517

2

GNU sed, 165 bytes

This script is based on the Retina answer by Martin Ender.

s/$/AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu/
s/[A-Z]/\n&: &/g
s/.//

Try it online!

Explanation:

s/$/AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu/
   # generate the alphabet words in concatenated form
s/[A-Z]/\n&: &/g
   # prepend '\nUL: ' before each upper-case letter (UL), getting the needed format
s/.//
   # delete the leading newline, plus implicit printing at the end

seshoumara

Posted 2017-03-07T08:31:11.370

Reputation: 2 878

2

SOGL, 91 bytes

╗D↕«∙φā¡75↔TI.½!γΜΧ…¡%<F┼0h╔κy|▓@TņV≈%⁹cr_σy░mgļΕžΕ⅝ »τ{M╔|«▼↔»aΓ²⁹┘′⅓G…└g↔bFΞ‽‘θ{KUtƧ: ooo

Explanation:

...‘θ{KUtƧ: ooo  that gibberish is a compressed string                 
...‘             push the compressed string of the words
    θ            split on spaces
     {           for each
      K          pop the 1st letter off & push it
       U         uppercase it
        t        output in newline a copy of the letter
         Ƨ: o    append ": "
             o   append the alphabet letter
              o  append the rest of the word

dzaima

Posted 2017-03-07T08:31:11.370

Reputation: 19 048

2

Bash, 184 bytes

printf '%c: %s
' {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}{,}

Try it online!

Dennis

Posted 2017-03-07T08:31:11.370

Reputation: 196 637

+1. The {,} trick in the brace expansion is a very clever way to double up each list member! – Digital Trauma – 2017-03-08T22:14:10.137

2

Lua, 177 bytes

print(("AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu"):gsub('%u',"\n%1: %1"):sub(2))

Try it online!

Without trailing newline, 180 bytes:

io.write(("AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu"):gsub('%u',"\n%1: %1"):sub(2))

Explanation

str = "AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu"
str = str:gsub('%u',"\n%1: %1") -- returns "\nA: Alfa...". %u matches uppercase letters, %1 returns matched letter in this case.
str = str:sub(2) -- remove added newline in the beginning
print(str) -- native print command

It uses Lua's string.gsub substitution function to pattern match the uppercase letters. The letters are then replaced with the requested format (plus the letters themselves). Newlines are also added on the same pass.

The sub-function at the end just trims out newline from the beginning and also works nicely to hide the second return value of gsub, which would have been the amount of replacements.

L. Koivunen

Posted 2017-03-07T08:31:11.370

Reputation: 21

2

PHP, 175 171 164 162 bytes

Note: no longer requires compressed file, uses IBM-850 encoding.

for($l=A;$c=LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu[$i++];)echo$c<a?"
$l: ".$l++:"",$c|~▀;

Run like this:

php -nr 'for($l=A;$c=LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu[$i++];)echo$c<a?"
$l: ".$l++:"",$c|~▀;';echo

Explanation

Prints every character individually (lowercased by OR with a space). If an uppercase character is encountered, it first prints a string of the form "\nA: A".

Tweaks

  • Saved 4 bytes by using another compression strategy
  • Saved 7 bytes by using a different delimiter (to combine assignment of $l with explode param), and not preventing a leading newline
  • Saved 2 bytes with a new method

aross

Posted 2017-03-07T08:31:11.370

Reputation: 1 583

2

C, 216 215 212 bytes

i=64,l;f(){for(char*s="lfAravOharliEeltAchOoxtroTolFoteLndiAulieTilOimAikEovembeRscaRapAuebeComeOierrAangOniforMictoRhiskeYraYankeEulU";++i<91;printf("%c: %c%.*s%c\n",i,i,l,s,s[l]+32),s+=l+1)for(l=0;s[++l]>90;);}

Try it online!

A detailed, human readable, well commented and perfectly valid (no compiler warnings) version of the program can be found below:

#include <stdio.h>

int main() {
    // Uppercase characters designate the last character of a word
    char*s="lfAravOharliEeltAchOoxtroTolFoteLndiAulieTilOimAikEovembeRscaRapAuebeComeOierrAangOniforMictoRhiskeYraYankeEulU";

    int i = 64; // Consecutive character
    int l; // Word length

    // Loop `i` from A to Z; Shift `s` with word length
    // `s` always points to the beginning of a word
    for( ; ++i < 91; s += l + 1 ) {
        // Increment `l` until you reach the next capital letter
        for( l = 0; s[++l] > 90 ;);
        // Print the current character, the word without it's last letter
        // and the last letter lowercased
        printf( "%c: %c%.*s%c\n", i, i, l, s, s[l]+32 );
    }
}

Itay Grudev

Posted 2017-03-07T08:31:11.370

Reputation: 146

1Welcome to PPCG! Nice first post! – Rɪᴋᴇʀ – 2017-03-08T21:28:02.737

@ceilingcat Not only the char*s but the printf could go in there too. Thus saving another 3 bytes - a semicolon and 2 curly braces as we no longer need them since there is only one instruction in it's body - the other for loop. – Itay Grudev – 2017-03-09T12:05:18.553

1

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);
    }
}

adrianmp

Posted 2017-03-07T08:31:11.370

Reputation: 1 592

1This is actually 17 bytes longer than the output... :P – Stewie Griffin – 2017-03-07T10:06:51.657

1@StewieGriffin: It's a full program, and C# didn't win awards for being minimalistic :P – adrianmp – 2017-03-07T10:18:10.847

2I know, it was just an observation :) – Stewie Griffin – 2017-03-07T10:32:18.153

4

You can golf it to 242 bytes like this.

– Kevin Cruijssen – 2017-03-07T12:59:59.107

1

Japt, 216 214 bytes

`A: Alfa
B: Bvo
C: Cr¦e
D: Delta
E: E®o
F: FoxÉ
G: Golf
H: HÇU
I: Iia
J: Jªiet
K: Kilo
L: La
M: Mike
N: Novem¼r
O: Os¯r
P: Papa
Q: Que¼c
R: Ro´o
S: Si
T: TÂ
U: Unifm
V: VÅ¡r
W: Wskey
X: Xy
Y: Ykee
Z: Zªu

Explaination: There is most likely a much better way to do it, but since i'm new I don't know it. I basically compressed the string with Oc" and put that string to be decompressed using Od"

If someone wants to help me save bytes by using something different from line breaks, I'd be happy to learn!

edit: Saved 2 bytes using ` instead of Od"

Martijn Vissers

Posted 2017-03-07T08:31:11.370

Reputation: 411

Using Try it online! it doesn't give the desired result :/

– ʰᵈˑ – 2017-03-07T09:59:29.577

@ʰᵈˑyes that could be, I didn't have enough time to check everything before I had to go to work. I might do it again (and better) after work. – Martijn Vissers – 2017-03-07T10:32:23.460

1

@ʰᵈˑ There are some unprintables in the string which don't show up in the Markdown. Try it online!

– ETHproductions – 2017-03-07T21:57:18.937

@ETHproductions ah thanks for that, I didn't know – ʰᵈˑ – 2017-03-08T08:35:00.397

1

Pyke, 89 bytes

.d⻵㡺ᐒଆຳ뼙΋ÒΗ䊊繎ㅨڨǔᯍⰬᐓ❤ᄵ㤉ተ᤬䆰髨⨈性dc Fl5DhRJ": 

Blue

Posted 2017-03-07T08:31:11.370

Reputation: 26 661

Do these characters happen to be in a specific single byte character set? – Adám – 2017-03-07T21:10:00.407

TIO gives a bad eval error and reports 161 bytes in the message. Either Pyke needs pushing there or something went wrong with a copy and paste here. @Adám if it was 1-1 it would be 41 bytes, utf-8 would be 88, but something definitely looks a bit off. – Jonathan Allan – 2017-03-07T21:43:56.513

@JonathanAllan it should be UTF-8. TIO runs it in not UTF-8. I think the byte-count might be wrong because it's measured as UTF-8 – Blue – 2017-03-08T17:38:47.623

1

Qbasic, 383 bytes

Not impressive, but for what it's worth:

dim a(1to 26)as string
a(1)="lfa
a(2)="ravo
a(3)="harlie
a(4)="elta
a(5)="cho
a(6)="oxtrot
a(7)="olf
a(8)="otel
a(9)="ndia
a(10)="uliet
a(11)="ilo
a(12)="ima
a(13)="ike
a(14)="ovember
a(15)="scar
a(16)="apa
a(17)="uebec
a(18)="omeo
a(19)="ierra
a(20)="ango
a(21)="niform
a(22)="ictor
a(23)="hiskey
a(24)="ray
a(25)="ankee
a(26)="ulu
for i=1to 26
?chr$(i+64);": ";chr$(i+64);a(i)
next

anonymous2

Posted 2017-03-07T08:31:11.370

Reputation: 421

Old BASIC memories… Can't those be stored in a data statement then read inside the for..next loop? – manatwork – 2017-03-07T21:25:25.090

@manatwork, that's a good idea; I hadn't thought of it! – anonymous2 – 2017-03-07T21:35:14.627

Wouldn't simply ?"A: Alfa" and so on be only 360 bytes? – oerkelens – 2017-03-09T15:47:34.880

@oerkelens, you could be right. I didn't even consider the possibility. :) – anonymous2 – 2017-03-09T16:42:02.560

1

///, 220 bytes

/;/: /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

Try it online!

-20 bytes thanks to @ETHproductions.

Comrade SparklePony

Posted 2017-03-07T08:31:11.370

Reputation: 5 784

It's not hard, and it saves 20 bytes: Try it online!

– ETHproductions – 2017-03-07T21:48:22.653

@ETHproductions I get it... for some reason I was overthinking it. I will update the answer. – Comrade SparklePony – 2017-03-07T21:54:14.860

1

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.

LegionMammal978

Posted 2017-03-07T08:31:11.370

Reputation: 15 731

1

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.

Oliver

Posted 2017-03-07T08:31:11.370

Reputation: 7 160

1

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.

– ETHproductions – 2017-03-08T18:24:58.157

1

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

manatwork

Posted 2017-03-07T08:31:11.370

Reputation: 17 865

1

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.

djeis

Posted 2017-03-07T08:31:11.370

Reputation: 281

1

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!

Jacob Persi

Posted 2017-03-07T08:31:11.370

Reputation: 111

1Welcome to the site! – James – 2017-03-10T20:06:16.277

1

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"

user5434231

Posted 2017-03-07T08:31:11.370

Reputation: 1 576

0

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%%

Neil

Posted 2017-03-07T08:31:11.370

Reputation: 95 035

0

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

Business Cat

Posted 2017-03-07T08:31:11.370

Reputation: 8 927

0

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

ElPedro

Posted 2017-03-07T08:31:11.370

Reputation: 5 301

0

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!

Ahemone

Posted 2017-03-07T08:31:11.370

Reputation: 608

1283: 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");} – jayjay – 2017-03-07T18:09:54.003

@jayjay kind of takes the fun out of it, doesn't it? – Ahemone – 2017-03-07T22:53:38.363

I will give you that! Yours is much more interesting. :) – jayjay – 2017-03-08T10:00:10.507

352 bytes – ceilingcat – 2019-11-13T02:46:16.687

0

C, 199 bytes

f(){char*s=" AlfaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJulietKiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTangoUniformVictorWhiskeyXrayYankeeZulu";while(*++s){printf("\n%c: %c"+*s/96*5,*s,*s);}}

Lynn

Posted 2017-03-07T08:31:11.370

Reputation: 55 648

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. – Itay Grudev – 2017-03-08T21:32:07.510

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. – Itay Grudev – 2017-03-09T12:26:15.603

And please, explain how this works: "\n%c: %c"+*s/96*5. – Itay Grudev – 2017-03-09T12:26:38.087

1@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. – Lynn – 2017-03-09T13:14:43.050

0

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;
}

Ángel

Posted 2017-03-07T08:31:11.370

Reputation: 286

0

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

CraigR8806

Posted 2017-03-07T08:31:11.370

Reputation: 480

1May I suggest to reorder the used instructions/functions? print$a=chr$i+++65,": $a\l$_\n"for split/(?=[A-Z])/,LfaRavoHarlieEltaChoOxtrotOlfOtelNdiaUlietIloImaIkeOvemberScarApaUebecOmeoIerraAngoNiformIctorHiskeyRayAnkeeUlu – manatwork – 2017-03-08T12:51:16.930

Nice! thanks, I'll update my code – CraigR8806 – 2017-03-08T12:57:06.320

0

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

idrougge

Posted 2017-03-07T08:31:11.370

Reputation: 641

0

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 _
    }
}

cookie

Posted 2017-03-07T08:31:11.370

Reputation: 271

0

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";

skeevey

Posted 2017-03-07T08:31:11.370

Reputation: 4 139