40
\$\begingroup\$

The Challenge:

Print every 2 letter word acceptable in Scrabble using as few bytes as possible. I have created a text file list here. See also below. There are 101 words. No word starts with C or V. Creative, even if nonoptimal, solutions are encouraged.

AA
AB
AD
...
ZA

Rules:

  • The outputted words must be separated somehow.
  • Case does not matter, but should be consistent.
  • Trailing spaces and newlines are allowed. No other characters should be outputted.
  • The program should not take any input. External resources (dictionaries) cannot be used.
  • No standard loopholes.

Wordlist:

AA AB AD AE AG AH AI AL AM AN AR AS AT AW AX AY 
BA BE BI BO BY 
DE DO 
ED EF EH EL EM EN ER ES ET EX 
FA FE 
GO 
HA HE HI HM HO 
ID IF IN IS IT 
JO 
KA KI 
LA LI LO 
MA ME MI MM MO MU MY 
NA NE NO NU 
OD OE OF OH OI OM ON OP OR OS OW OX OY 
PA PE PI 
QI 
RE 
SH SI SO 
TA TI TO 
UH UM UN UP US UT 
WE WO 
XI XU 
YA YE YO 
ZA
\$\endgroup\$
  • 8
    \$\begingroup\$ Do the words have to be outputted in the same order? \$\endgroup\$ – Sp3000 Aug 13 '15 at 3:26
  • 2
    \$\begingroup\$ @Sp3000 I'll say no, if something interesting can be thought up \$\endgroup\$ – qwr Aug 13 '15 at 3:29
  • 2
    \$\begingroup\$ Please clarify what exactly counts as separated somehow. Does it have to be whitespace? If so, would non-breaking spaces be allowed? \$\endgroup\$ – Dennis Aug 13 '15 at 14:14
  • 5
    \$\begingroup\$ Ok, found a translation \$\endgroup\$ – Mikey Mouse Aug 13 '15 at 15:16
  • 3
    \$\begingroup\$ Vi isn't a word? News to me... \$\endgroup\$ – jmoreno Aug 15 '15 at 15:23

39 Answers 39

39
\$\begingroup\$

Python 3, 194 188 bytes

s="BI ODEXIF BAAX ASOHER LOXUMOPAGOR KI US AMY BOITONOSI MMEMINANEHI UPI AYAHOYOWOMUNUHAID PEFARED QIS BEN JOFETAE KAT ABYESHMALI UTI ZADOELAWE "
while s:" "in s[:2]or print(s[:2]);s=s[1:]

Almost definitely not the shortest method, but I thought this would be a good start. Try to pack each pair into paths by overlapping as much as possible (e.g. "ODEX..." = ["OD", "DE", "EX", ...]). Spaces are used to separate paths, and any pairs with a space in it is removed (the trailing space is to prevent a single E from being printed at the end).

I also tried regex golfing this but it was longer.

\$\endgroup\$
  • 1
    \$\begingroup\$ +1 nice approach! I Borrowed your string for a Ruby answer \$\endgroup\$ – daniero Aug 13 '15 at 20:52
  • \$\begingroup\$ I also made an answer based on your idea using bash and regex \$\endgroup\$ – sergioFC Aug 14 '15 at 10:36
  • 2
    \$\begingroup\$ +1 for AYAHOYOWOMUNUHAID! \$\endgroup\$ – Level River St Aug 15 '15 at 0:02
28
\$\begingroup\$

CJam, 96 94 bytes

0000000: 31 30 31 2c 22 5a 0a d0 fd 64 f6 07 a3 81 30 f2  101,"Z...d....0.
0000010: c2 a5 60 0c 59 0f 14 3c 01 dd d1 69 7d 66 47 6e  ..`.Y..<...i}fGn
0000020: db 54 e5 8f 85 97 de b9 79 11 35 34 21 cb 26 c3  .T......y.54!.&.
0000030: f0 36 41 2b b4 51 fb 98 48 fc cb 52 75 1f 1d b1  .6A+.Q..H..Ru...
0000040: 6b c3 0c d9 0f 22 32 36 30 62 33 36 62 66 7b 3c  k...."260b36bf{<
0000050: 31 62 32 35 6d 64 2d 35 35 7d 27 41 66 2b        1b25md-55}'Af+

The above is a hexdump, which can be reversed with xxd -r -c 16 -g 1.

Try it online in the CJam interpreter.

Depending on what exactly counts as separated somehow, the byte count could be lowered to 93 or even 92:

  • If we replace -55 with 59, the words will be separated by non-breaking spaces (0xA0).

  • If we replace -55 with W, the words will be separated by at-signs (0x40).

Idea

We can encode each pair of letters xy as (ord(x) - 65) × 25 + (ord(y) - 65).1

Instead of storing the resulting integers, we'll store the differences of all pairs that correspond to two adjacent words (sorted alphabetically).

The highest difference is 35, so we consider them digits of a base 36 integer and convert that integer into a a byte string.

Code

101,   e# Push [0 ... 100].
"…"    e# Push the string that encodes the differences/increments.
260b   e# Convert from base 260 to integer.
36b    e# Convert from integer to base 36 (array).
f{     e# For each I in [0 ... 100]:
       e#   Push the base 36 array.
  <    e#   Keep it's first I elements.
  1b   e#   Compute their sum.
  25md e#   Push quotient and residue of the sum's division by 25.
  -55  e#   Push -55 = '\n' - 'A'.
}      e#
'Af+   e# Add 'A' to all resulting integers. This casts to Character.

1 Since the second letter is never a Z, using 25 instead of 26 is enough.

\$\endgroup\$
14
\$\begingroup\$

PHP 224, 218, 210 206

foreach(explode(",","I19SR,9ZY8H,,CNK,5JRU0,H,CN4,G0H,H160,CN4,75,CU9,AMIHD,MTQP,HQOXK,7L,74,G,CXS,CU9,HTOG,,CNK,MHA8,CNL,1")as$a){$b++;for($c=0;$c<26;$c++)echo base_convert($a,36,10)&pow(2,$c)?chr(96+$b).chr(97+$c)." ":"";}
aa ab ad ae ag ah ai al am an ar as at aw ax ay ba be bi bo by de do ed ef eh el em en er es et ex fa fe go ha he hi hm ho id if in is it jo ka ki la li lo ma me mi mm mo mu my na ne no nu od oe of oh oi om on op or os ow ox oy pa pe pi qi re sh si so ta ti to uh um un up us ut we wo xi xu ya ye yo za 

Definitely not a great score, but I liked the challenge.

I create a table of the options, created a bitwise system to flag which options are valid.

enter image description here

Then I base-36 encoded those options to get the string:

"I19SR,9ZY8H,,CNK,5JRU0,H,CN4,G0H,H160,CN4,75,CU9,AMIHD,MTQP,HQOXK,7L,74,G,CXS,CU9,HTOG,,CNK,MHA8,CNL,1"

Note the 3rd entry in that string array doesn't have a value, because C has no options.

To print the values, I just convert the valid options to chars.

There might be something I could do to reduce recognising that there are no words ending in C, J, K, Q, V or Z, but I can't think of a method to reduce it atm.


By transposing the table, there are more empty elements and the data encodes a little more compactly which shaved off a few bytes. The array is now printed in a different order:

foreach(explode(",","UB1YB,1,,CUP,CLMEJ,CUO,1,SG0H,5J9MR,,,H,MX01,MTXT,CYO5M,MTQ8,,CNL,MTXT,MHAP,50268,,CN5,CNL,FSZ,,")as$a){$b++;for($c=0;$c<26;$c++)echo base_convert($a,36,10)&pow(2,$c)?chr(97+$c).chr(96+$b)." ":"";} 

aa ba fa ha ka la ma na pa ta ya za ab ad ed id od ae be de fe he me ne oe pe re we ye ef if of ag ah eh oh sh uh ai bi hi ki li mi oi pi qi si ti xi al el am em hm mm om um an en in on un bo do go ho jo lo mo no so to wo yo op up ar er or as es is os us at et it ut mu nu xu aw ow ax ex ox ay by my oy

Thanks to Ismael for the explode and for loop hints.

foreach(explode(3,UB1YB3133CUP3CLMEJ3CUO313SG0H35J9MR333H3MX013MTXT3CYO5M3MTQ833CNL3MTXT3MHAP35026833CN53CNL3FSZ)as$d)for($e++,$f=0;$f<26;$f++)echo base_convert($d,36,10)&pow(2,$f)?chr(97+$f).chr(96+$e)." ":"";

With an update to php5.6, pow(,) can be replaced by ** saving another 4 bytes.

foreach(explode(3,UB1YB3133CUP3CLMEJ3CUO313SG0H35J9MR333H3MX013MTXT3CYO5M3MTQ833CNL3MTXT3MHAP35026833CN53CNL3FSZ)as$d)for($e++,$f=0;$f<26;$f++)echo base_convert($d,36,10)&2**$f?chr(97+$f).chr(96+$e)." ":"";
\$\endgroup\$
  • \$\begingroup\$ Instead of exploding by ",", you can use explode(0,UB1YB0100CUP[...]) \$\endgroup\$ – Ismael Miguel Aug 13 '15 at 15:11
  • \$\begingroup\$ Wouldn't that break since there are 0s in the encoding? \$\endgroup\$ – James Webster Aug 13 '15 at 15:13
  • \$\begingroup\$ However.. there isn't a 3 I can use that! Thanks \$\endgroup\$ – James Webster Aug 13 '15 at 15:16
  • \$\begingroup\$ Also, you can replace $e++;for($f=0;$f<26;$f++) with for($e++,$f=0;$f<26;$f++), and now you can remove those pesky {}. And if you want to convert chars to lowercase, use $e^' '. \$\endgroup\$ – Ismael Miguel Aug 13 '15 at 15:41
  • \$\begingroup\$ Good catch! I wouldn't have got that one. \$\endgroup\$ – James Webster Aug 13 '15 at 15:43
8
\$\begingroup\$

Perl, 167 164 157 bytes

"AMAEDOXUHALAXISHENUNUPABEFAHIDEMYESOHOSITAAGOYAYAWOWETOINODOREX KIFEHMMER BYONELI BOEMUS PELOMI UMOFAD BATAR KANAS JOPI UTI ZAI BI QI"=~/$_/&&say for AA..ZZ

Wrote a separate script to group the letters together as compact as possible into a string that contained all the valid 2 letter words. This then iterates over all of the two letter words and prints the valid ones, one per line. Run with perl -M5.10.1 script.pl.

\$\endgroup\$
  • \$\begingroup\$ I can't get this to work in an online compiler. \$\endgroup\$ – mbomb007 Aug 14 '15 at 20:00
  • \$\begingroup\$ @mbomb007 Depending on the version, you either need the command line flag -M5.10.1 to use the say keyword added in that version, or add use feature 'say'; in the body of the script. \$\endgroup\$ – AKHolland Aug 15 '15 at 12:45
7
\$\begingroup\$

C,155 bytes

Golfed version

i,v;main(){for(;++i-408;" >b  Ùc :oÒ¹ i ;¹ w so@)ia ¥g¨¸ ´k¦ase    Ù{§k {"[i/8]>>i%8&1||printf("%c%c%c ",i/8%2*v,i/16+65,!(i/8%2)*v))v="YUOIEMHA"[i%8];}

Output

YA HA AA BY BO BI BE BA AB DO DE OD ID ED AD YE OE HE AE FE FA OF IF EF GO AG UH OH EH AH OI HI AI JO KI KA LO LI LA EL AL MY MU MO MI ME MM MA UM OM EM HM AM NU NO NE NA UN ON IN EN AN YO HO PI PE PA UP OP QI RE OR ER AR SO SI SH US OS IS ES AS TO TI TA UT IT ET AT WO WE OW AW XU XI OX EX AX OY AY ZA

Ungolfed version

The 51-byte magic string in the golfed version contains many characters beyond ASCII 126, which have almost certainly been mangled into Unicode equivalents. The ungolfed version uses hex instead, and as a constant rather than a literal. Also, the ungolfed version separates the words with a newline, which makes it easier to copy and paste into Excel, order the list and compare with the required one.

char a[]=
{0xFF,0x3E ,0x62,0x7F ,0xFF,0xFF ,0xEB,0x63 ,0xFF,0x3A ,0x6F,0xE3 ,0xFB,0x7F ,0xFF,0x69 ,0xFF,0x3B
,0xFB,0xFF ,0x77,0xFF ,0x73,0x6F ,0x40,0x29 ,0x69,0x61 ,0xFF,0xBE ,0x67,0xF9 ,0xF7,0xFF ,0xEF,0x6B
,0xB3,0x61 ,0x73,0x65 ,0xFF,0xFF ,0xFF,0xFF ,0xEB,0x7B ,0xF5,0x6B ,0xFF,0x7B ,0x7F};

//iterate through i = 16*letter + 8*order + vowel
i,v;main(){for(;i++-408;a[i/8]>>i%8&1||printf("%c%c%c\n",i/8%2*v,i/16+65,!(i/8%2)*v))v="YUOIEMHA"[i%8];}

Explanation

If we expand the definition of vowel to include the 8 letters AHMEIOUY, we observe that all words consist of one vowel and one other letter (which may or may not be a vowel.) Therefore, for all the words ending in a vowel, we need a table of 26 bytes, one for each first letter, with the individual bits corresponding to the vowel. We need a similar table for the words starting with a vowel, except that this time we only need 25 bytes, as there is no word ending in Z. The two tables are riffled together to create the final table.

In order to avoid any ASCII codes in the region 0..31, the two least common "vowels" M and H are assigned to the 6th and 7th bit, and the encoding considers 1 for an invalid word and 0 for a valid word. Since there is no consonant which pairs with both M and H it is possible to ensure at least one of these bits is a 1.

The 8th bit is assigned to A, which is the most common vowel, to try to limit the non-ASCII characters (still there are rather a lot of them.)

The tables used are below. For words containing 2 vowels, I gave priority to the first letter as being considered the "vowel" and the second letter as the "letter." An exception to this is words starting with M, as this avoids a clash between MM and HM.

Hex encoding of words starting with a vowel

3E 7F FF 63 3A E3 7F 69 3B FF FF 6F 29 61 BE F9 FF 6B 61 65 FF FF 7B 6B 7B

AA AB    AD AE    AG AH AI       AL AM AN          AR AS AT       AW AX AY 
HA          HE          HI          HM    HO 

         ED    EF    EH          EL EM EN          ER ES ET          EX 
         ID    IF                      IN             IS IT 
         OD OE OF    OH OI          OM ON     OP   OR OS          OW OX OY 
                     UH             UM UN     UP       US UT 
YA          YE                            YO 

Hex encoding of words ending with a vowel

 A  H  M  E  I  O  U  Y
                         FF
BA       BE BI BO    BY  62
                         FF 
         DE    DO        EB
                         FF
FA       FE              6F
               GO        FB
                         FF
                         FF
               JO        FB
KA          KI           77
LA          LI LO        73
MA    MM ME MI MO MU MY  40
NA       NE    NO NU     69
                         FF
PA       PE PI           67
            QI           F7
         RE              EF
    SH      SI  SO       B3
TA          TI  TO       73
                         FF
                         FF
         WE     WO       EB
            XI     XU    F5
                         FF
ZA                       7F
\$\endgroup\$
  • \$\begingroup\$ Maybe make a hexdump of the golfed version so the mangling can be reverted easily \$\endgroup\$ – masterX244 Sep 20 '15 at 15:23
7
\$\begingroup\$

Java, 484 448 407 391 389 bytes

My first try

public static void main(String[]a){int[]x={57569742,35784706,0,2099200,5534148,35651584,2048,35792896,5247168,2048,33685504,33687552,35794978,35653664,7746958,35782656,131072,2097152,395264,33687552,551296,0,2099200,131104,35653632,33554432};for(Integer i=0;i<26;i++){for(int z=0;z<26;z++){if("".format("%26s",i.toString(x[i],2)).charAt(z)=='1'){System.out.format("%c%c ",'A'+i,'A'+z);}}}}

Formatted:

public static void main(String[] a) {
    int[] x = { 57569742, 35784706, 0, 2099200, 5534148, 35651584, 2048, 35792896, 5247168, 2048, 33685504, 33687552, 35794978, 35653664,
            7746958, 35782656, 131072, 2097152, 395264, 33687552, 551296, 0, 2099200, 131104, 35653632, 33554432 };
    for (Integer i = 0; i < 26; i++) {
        for (int z = 0; z < 26; z++) {
            if ("".format("%26s", i.toString(x[i], 2)).charAt(z) == '1') {
                System.out.format("%c%c ", 'A' + i, 'A' + z);
            }
        }
    }
}

Try it online

\$\endgroup\$
  • \$\begingroup\$ Nice job! Some suggestions: java.lang.Exception can just be called Exception. "args" can be just "a". String.format() can be "".format(). There is also a little extra spacing in the main() declaration. Nice approach overall though, +1 from me :) \$\endgroup\$ – jrich Aug 13 '15 at 16:57
  • \$\begingroup\$ I've just been playing with the print statement, but you beat me to it! You can save another byte by replacing \n with just a space. They don't have to be separated by new lines. \$\endgroup\$ – James Webster Aug 14 '15 at 9:35
  • \$\begingroup\$ You've also missed a few spaces that you can remove. \$\endgroup\$ – James Webster Aug 14 '15 at 9:37
  • \$\begingroup\$ @JamesWebster thx for the hints. \$\endgroup\$ – griFlo Aug 14 '15 at 10:11
  • 4
    \$\begingroup\$ "".format is painful to look at, but hilarious. \$\endgroup\$ – codebreaker Aug 14 '15 at 19:59
6
\$\begingroup\$

Ruby, 166 bytes

Borrowing sp3000's neat method for encoding the words into a compact string. The kicker here is the short method for decoding it back into the two-letter words: Using a lookahead in the regex passed to String's scan method in order to extract overlapping matches, not containg space:

puts "BI ODEXIF BAAX ASOHER LOXUMOPAGOR KI US AMY BOITONOSI MMEMINANEHI UPI AYAHOYOWOMUNUHAID PEFARED QIS BEN JOFETAE KAT ABYESHMALI UTI ZADOELAWE".scan /(?=(\w\w))/

Ruby, 179 bytes

My own approach: Generate all two-letter words between AA and ZA, and select the valid ones using a base 36 encoded bitmask:

i=-1
puts ("AA".."ZA").select{|w|"djmsjr5pfw2omzrfgydo01w2cykswsrjaiwj9f2moklc7okcn4u2uxyjenr7o3ub90fk7ipdq16dyttg8qdxajdthd6i0dk8zlmn5cmdkczrg0xxk6lzie1i45mod7".to_i(36)[i+=1]>0}
\$\endgroup\$
6
\$\begingroup\$

Matlab, 177 bytes

Generate a binary matrix defining all allowed pairs of letters, reshape it and base-64 encode it. The base-64 encoded string ('CR+ ... % ') is used as data in the program. The program reverses operations to unpack the matrix, and then reads the allowed pairs:

x=de2bi('CR+"''        1$$ L*\"%$!! !   $!04P@<W(        0$   1"%$$100@RZP4  $$    0$ ! 1$$$$1 0  P (    $ 0 0$ ! # %  '-32)';[i,j]=find(reshape(x(1:650),26,[])');char([j i]+64)
\$\endgroup\$
  • 2
    \$\begingroup\$ Nice one Luis! Golfing is actually kind of fun... =P \$\endgroup\$ – Stewie Griffin Aug 14 '15 at 7:56
  • 1
    \$\begingroup\$ Nice! There is no alphabet! \$\endgroup\$ – Brain Guider Aug 14 '15 at 9:07
  • 1
    \$\begingroup\$ hats off. This is the most cryptic matlab code i've seen in ages ... \$\endgroup\$ – Hoki Aug 14 '15 at 15:32
  • \$\begingroup\$ Thanks guys! It's only cryptic because of the base-64 encoding. That string actually packs the 26x25 binary matrix of allowed letter pairs \$\endgroup\$ – Luis Mendo Aug 14 '15 at 21:31
6
\$\begingroup\$

Malbolge, 2118 bytes

D'``_#>nI||38h6/vdtO*)_^mI7)"XWfB#z@Q=`<)\xwvuWm32ponmfN+ibJfe^$\[`Y}@VUySXQPUNSLpJINMLEiC+G@EDCB;_?>=}|492765.R210p(-,+*#G'&feB"baw=u]sxq7Xnsrkjoh.fNdchgf_%]\a`Y^W{>=YXWPOsSRQ3OHMLKJIBfF('C<`#"8=<;:3W1w5.R2+q/('&J$)"'~D$#"baw=utsxq7Xnsrkjoh.fNdchgf_%c\D`_X|\>=YXWPOsSRQ3OHMLKJIBfFEDC%$@9]=6|:32V6/.3210)M-m+$)"'&%|Bcb~w|u;yxwvuWm3kpinmfe+ihgfH%cb[ZY}]?UZYRWVOs65KPIHGkKJIH*)?c&BA@?8\6|:32V6/.3210)M-,lk)"F&feBzbxw=uzyrwpon4Ukpi/mfkdc)g`ed]#DZ_^]VzZ<;QPt7MLQPOHlFEJIHAe(>C<;_?>765:981Uv.32+*)Mnm%$)(!Efe{zy?}|{zyxqpo5mrkpoh.fNdihg`ed]#DZ_^]Vz=YRQuUTMqQ32NMLEDhHG@(>C<;_?>76;:3W76v43,+O/.nm+*)"Fgf${z@a}v{zyr8vo5Vrqj0nmfN+Lhg`_%cbDCY}@VUySRWPt76Lp3ONMLEDhHG@(>C<;_"8\6|:32V0v.Rs10/.'&+$H('&feB"!x>|^]srwvun4Ukpi/gfe+Lbaf_%cE[`Y}@?[TxRWPUNMLKo2NGFjD,BAeED&<A:^>=6|:32V6v.R21*/(L,+*#"!E}|{z@xw|{t:[qpotsrk1Rhmlkd*Kgfe^$bDZ_^]VzZ<;QuUTMqKJOHGkEJCBA@dD=<;:^>=6|:32V654t,+O).',+*#G'&feBzbx>|^]yr8vXnsrkjoh.fkdcbg`&^Fba`Y^WVzZ<XWPUTMqQ3INMFjD,BAe?>=B;_9>7<54X8765u-Q10)o'&J$)"!~%${A!x}v<]\xwpun4rTpoh.leMchgf_d]#DZ_^]VzZYR:Pt7SLKPOHlFEJIHAeED&<`@"87<5Y98165.3,P*/(-&+$H(!~}C#c!x}|u;\[wvun4lTjih.fN+Lbgfe^c\"CY}@VUyYXWPOsSRKJIHlLE-IBAeE'&<`@"87<5Y98165.3,Pq/.-,+*#G'&fe#"!x>|{zyr8Yotml2ponPlkdcb(fH%]\[`Y^W{zZ<XWPUTMq4JIHMLEi,BA@d>=B;:9]7};:3W7wv.3,+O)o'&J*)('g%${Ay~}v{zyrq7otmrqpoh.fejiha'eG]\[ZY}@VUy<;WVOsSRQPImM/KJIBAe(>=aA:^>=6|:32V65u-Qr0/.'K+$j"'~De#zy~wv<]yrqpo5srkjohg-kdib(feG]b[Z~^]\UTYRvP8TSRKJIHlLKD,BAe?>=B;_?>7<;:981U54t,+O)o'&Jkj('&}C#"bx>_{tyr8vuWVl2pihgle+ihgfH%cEDZ~XWVUy<XWPUTMqQP2NGLEiCBGF?>b%A@?87[;:zy1U54t210/.'K+$j"'~De#zy~wv<zyxwp6Wmlqpohg-kdib(feG]ba`Y^W{>=YXWPOs65KJIHl/KJIBA@dDCB;:9]=<;:zy1Uvu3,P0)o'&J$#(!~D|#"y?}v{zyr8vXnml2ponPledc)gfH%c\D`_^]VzZ<;QVOTSLpPIHGkKJCBG@dD=<;:^>=6|:32Vw543,+*N.nm+*)"F&feB"y~}|{ts9qvonsl2ponmfN+Lha`e^$\[Z_X|\UTYRQVOsM5KJOHGFjD,BA@d>=B;:9]=};4X81w5.R210)o'&J$j"'~%|{"y?w_u;y[wpun4Ukponmfe+Lha'eGc\[!B^WV[TxXQ9ONrRQ32NMLEDh+AeE'&<`#"8=<;:3W7wv.3,+O/.'m+*)(!EfeBcbx>_{tsxwvun4Ukpi/POkdcha'_d]#DZ_^]VzZ<RQPUNMqQ3ONGkE-IBAeED=BA:9]=<|43870/St,+O/.-ml*)(!Ef|Bcb~w|u;y[Zvun4rTpoh.fN+cKgf_%cE[!BXWV[ZSwWP8TSLpJIHMLEJIBf)d'=aA@">=<5Y98165.3,Pq)('K%*#"!EfeBcyxwvu;yxwvuWm3~

Try it online!

\$\endgroup\$
5
\$\begingroup\$

Bash, 179 bytes

echo U`sed -r 's/./& &/g'<<<HAABADEDOEFAEHELAGOFEMAHINAISHMENERESITALOHOMMONOPAMUMYAWETOSOWOYOXUNUPEXI`F `grep -o ..<<<ANARASATAXAYBEBIBOBYJOKAKILIMIOIDOIDORPIQITIUSUTYEZA`
  • Saved 7 bytes thanks to Adam Katz comment

It uses sed to do regex replacement. First regex input is based on Sp3000 idea while second regex uses common input without spaces.

Explanation:

echo              print to standard output the following
U                 boundary U character
sed -r [etc]      the result of replacing regex
    .             select a character
    & &           replace it for: matched char, space, matched char
    g             do it globaly for every character
    <<<HAAB[etc]  string input based on Sp3000 idea => HA AA AB ...
F                 boundary F character
sed -r [etc]      the result of replacing regex
    ..            every two characters
    <space>&      for space+matched character
    g             do it globally
    <<<ANAR       normal input => AN AR ...
\$\endgroup\$
  • 1
    \$\begingroup\$ You can shrink that by seven bytes using a space and then `grep -o .. in place of `sed -r 's/ / &/g', a trick from my answer below. \$\endgroup\$ – Adam Katz Jan 23 '17 at 19:28
5
\$\begingroup\$

Warning, this answer is not programmatically interesting.

Since all words are two characters long, we can smash them all together and then rip them apart again using a simple regular expression.

Any regex-friendly language can do this, some more efficiently than others:

Grep (via Bash), 215 bytes

grep -o ..<<<AAABADAEAGAHAIALAMANARASATAWAXAYBABEBIBOBYDEDOEDEFEHELEMENERESETEXFAFEGOHAHEHIHMHOIDIFINISITJOKAKILALILOMAMEMIMMMOMUMYNANENONUODOEOFOHOIOMONOPOROSOWOXOYPAPEPIQIRESHSISOTATIT

Javascript, 224 bytes

alert("AAABADAEAGAHAIALAMANARASATAWAXAYBABEBIBOBYDEDOEDEFEHELEMENERESETEXFAFEGOHAHEHIHMHOIDIFINISITJOKAKILALILOMAMEMIMMMOMUMYNANENONUODOEOFOHOIOMONOPOROSOWOXOYPAPEPIQIRESHSISOTATITOUHUMUNUPUSUTWEWOXIXUYAYEYOZA".match(/../g))

Perl, 225 bytes

 $_="AAABADAEAGAHAIALAMANARASATAWAXAYBABEBIBOBYDEDOEDEFEHELEMENERESETEXFAFEGOHAHEHIHMHOIDIFINISITJOKAKILALILOMAMEMIMMMOMUMYNANENONUODOEOFOHOIOMONOPOROSOWOXOYPAPEPIQIRESHSISOTATITOUHUMUNUPUSUTWEWOXIXUYAYEYOZA";s/../$&\n/g;print

Python, 245 bytes

import re
print re.sub(r'..','\g<0>\n',"AAABADAEAGAHAIALAMANARASATAWAXAYBABEBIBOBYDEDOEDEFEHELEMENERESETEXFAFEGOHAHEHIHMHOIDIFINISITJOKAKILALILOMAMEMIMMMOMUMYNANENONUODOEOFOHOIOMONOPOROSOWOXOYPAPEPIQIRESHSISOTATITOUHUMUNUPUSUTWEWOXIXUYAYEYOZA")

 


As a note, some of the answers here are longer than echo, which I'd consider a baseline:

POSIX shell, 307 bytes

echo AA AB AD AE AG AH AI AL AM AN AR AS AT AW AX AY BA BE BI BO BY DE DO ED EF EH EL EM EN ER ES ET EX FA FE GO HA HE HI HM HO ID IF IN IS IT JO KA KI LA LI LO MA ME MI MM MO MU MY NA NE NO NU OD OE OF OH OI OM ON OP OR OS OW OX OY PA PE PI QI RE SH SI SO TA TI TO UH UM UN UP US UT WE WO XI XU YA YE YO ZA
\$\endgroup\$
  • 3
    \$\begingroup\$ +1 for being practical. Really, providing the base echo is the point everyone should start from. \$\endgroup\$ – metalim Aug 15 '15 at 10:18
  • \$\begingroup\$ +1 on easy answer, but you should be marking that as non competing, shouldn't you? \$\endgroup\$ – Matthew Roh Jan 24 '17 at 1:32
  • \$\begingroup\$ @MatthewRoh – If there were a leader-board parser, it would probably fail to find anything since I intentionally didn't start with a heading. I'm not worried, especially since there are shorter answers for every language I've posted. \$\endgroup\$ – Adam Katz Jan 24 '17 at 1:55
3
\$\begingroup\$

C - 228 217 Bytes - GCC

 _;main(){char *z,*i="AABDEGHILMNRSTWXY AEIOY  EO DFHLMNRSTX AE O AEIMO DFNST O AI AIO AEIMOUY AEOU DEFHIMNPRSWXY AEI I E HIO AIO HMNPST  EOU IEO A A ";for(z=i;_++^26;)for(;*++z^32;putchar(_+64),putchar(*z),puts(""));}

Will update if I can get it smaller, just compile with gcc -w, ./a.out outputs perfectly. If there's any interest in an ungolfed, let me know.

I can't think of any way to shorten it off the top of my head, (you can technically remove the quotes in puts and you'll still get a correct answer, the output just looks like garbage) so please let me know of anyways to shorten it

\$\endgroup\$
  • \$\begingroup\$ Here's a few suggestions, it runs fine for me (don't just copy and paste, stack exchange inserts weird control characters into comments)_;main(){char*z="AABDEGHILMNRSTWXY AEIOY EO DFHLMNRSTX AE O AEIMO DFNST O AI AIO AEIMOUY AEOU DEFHIMNPRSWXY AEI I E HIO AIO HMNPST EOU IEO A A ";for(;_++^26;)for(;*++z^32;printf("%c%c ",_+64,*z));} I've changed the output delimiter from a newline to a space, but if you prefer a newline (one extra byte) change the printf format string to "%c%c\n" \$\endgroup\$ – Level River St Aug 14 '15 at 19:30
3
\$\begingroup\$

C#, 348 bytes

I had a go:

using System;class A{static void Main(){var a=new System.Collections.BitArray(Convert.FromBase64String("tnOciwgCCAAAAAggAFBxHIkAAAAACICIKABQQBgAAAIgIACAgCAAIqIgigCCADfWuIgAAAACAIAAAAAwCICAIAAAYRkAAAAAAggAgAAIIoAACA=="));int c, d;for(var i=0;i<652;i++){if(a[i]){c=Math.DivRem(i,26,out d);Console.Write("{0}{1} ",(char)('A' + c),(char)('@' + d));}}}}

Ungolfed:

using System;

class A
{
    static void Main()
    {
        var a = new System.Collections.BitArray(Convert.FromBase64String(
            "tnOciwgCCAAAAAggAFBxHIkAAAAACICIKABQQBgAAAIgIACAgCAAIqIgigCCADfWuIgAAAACAI" + 
            "AAAAAwCICAIAAAYRkAAAAAAggAgAAIIoAACA=="));
        int c, d; 
        for(var i = 0; i < 652; i++)
        {
            if(a[i])
            {
                c = Math.DivRem(i, 26, out d);
                Console.Write("{0}{1} ", (char)('A' + c), (char)('@' + d));
            }
        }
    }
}
\$\endgroup\$
  • 4
    \$\begingroup\$ This is a codegolf challenge, so you should post your byte-count (length of your code). Also try to shorten it a bit, for instance by removing whitespace. \$\endgroup\$ – Jakube Aug 13 '15 at 13:56
  • \$\begingroup\$ @Jakube, is that better? \$\endgroup\$ – Jodrell Aug 13 '15 at 16:21
  • \$\begingroup\$ Yes, looks o.k. \$\endgroup\$ – Jakube Aug 13 '15 at 18:51
3
\$\begingroup\$

Pyth, 140 bytes

K"aeiou"=H+-G+K\zKL.[`Z25.Bib32jdSfTs.e.e?nZ`0+@Gk@HY""byMc"ljjns 1u  a 6jji0 o 2 100u 60hg0 2 k m 101v r 6hr7c s 4 8 g006 m hpg0  a 5 q g"d

Try it online!

Compression method: Since there's no Z in the second position of any word, use the reordered alphabet bcdfghjklmnpqrstvwxyaeiou to encode the validity of each of those letters as a second letter for each first letter (first letters are in alphabetical order).
This is 25 bits per letter, or exactly 5 Base-32 digits. Since most consonants only take vowels as the second letter, I put vowels at the end to get mostly 1-digit numbers for them. I'm sure it could overall be improved by further analysis and reordering of the alphabet, although then the definition of the reordered alphabet would take up more bytes.

Explanation

K"aeiou"=H+-G+K\zK # Define the reordered alphabet
K"aeiou"           # K := "aeiou"
        =H         # H :=
           -G      #      G.removeAll(
             +K\z  #                   K + "z" 
          +      K #                           ) + K

L.[`Z25.Bib32      # Define a lambda function for decompression
L                  # y = lambda b:
         ib32      # convert b to int using Base 32
       .B          # convert to binary string
 .[`Z25            # pad to the left with "0" to the nearest multiple of 25 in length

                           c"..."d # split the compressed string on " "
                         yM        # Apply y (above lambda) to each element
                                   #   Intermediate result: List of binary strings
                                   #   with 1s for allowed combinations
      .e                           # map over ^ lambda b (current element), k (current index):
        .e              b          # map over b: lambda Z (cur. elem.), Y (cur. ind.):
               +@Gk@HY             # G[k] + H[Y] (G is the regular alphabet)
          ?nZ`0       ""           #     if Z != "0" else ""
     s                             # combine into one large list
   fT                              # remove all falsy values (empty strings)
  S                                # sort (if any order is possible, remove this)
jd                                 # join on spaces (if a normal list with the words is
                                   #   allowed, remove this)
\$\endgroup\$
2
\$\begingroup\$

PHP: 211 209 204

You have to turn warnings off, otherwise one will print in regards to the implicit creation of $b

for($a=65;$b<strlen($c="ABDEGHILMNRSTWXY!AEIOY!EO!DFHLMNRSTX!AE!O!AEIMO!DFNST!O!AI!AIO!AEIMOUY!AEOU!DEFHIMNPRSWXY!AEI!I!E!HIO!AIO!HMNPST!EO!IU!AEO!A");$b++)if($c[$b]!='!')echo chr($a).$c[$b].' ';else$a++;

Very fun. Early attempts were in the 250 range, but this is my slimmest yet.

\$\endgroup\$
  • 2
    \$\begingroup\$ Try this byte counter. Note that turning off whitespace counting is incorrect, since it also discounts any spaces you have in strings, so your score should be more than 186. \$\endgroup\$ – Sp3000 Aug 13 '15 at 15:15
  • \$\begingroup\$ Good catch. I've updated my submission accordingly \$\endgroup\$ – NickW Aug 13 '15 at 15:23
  • \$\begingroup\$ I can't see why.. but this now just prints "A A A A A..." \$\endgroup\$ – James Webster Aug 13 '15 at 15:28
  • \$\begingroup\$ You've taken out the ! on the if.. you needed that. \$\endgroup\$ – James Webster Aug 13 '15 at 15:31
  • \$\begingroup\$ Right. I just noticed that. I was using ! delimiter earlier and I did a quick find-replace without considering what would happen first. \$\endgroup\$ – NickW Aug 13 '15 at 15:34
2
\$\begingroup\$

CJam (99 bytes)

This includes a few special characters, so it's safest to give a hexdump. (In particular, the character with value 0xa0, corresponding to a non-breaking space, caused me quite a bit of trouble in setting up the online demo).

00000000  36 37 36 22 c4 b2 2d 51  3f 04 93 5c 64 6c 8d 6e  |676"..-Q?..\dl.n|
00000010  d7 f9 7d 97 29 aa 43 ef  04 41 12 e1 aa ce 12 4d  |..}.).C..A.....M|
00000020  05 f3 1c 2b 73 43 a0 f0  41 c0 a7 33 24 06 37 a3  |...+sC..A..3$.7.|
00000030  83 96 57 69 9b 91 c4 09  c3 93 e1 ed 05 3b 84 55  |..Wi.........;.U|
00000040  d9 26 fd 47 68 22 32 35  36 62 33 38 62 7b 31 24  |.&.Gh"256b38b{1$|
00000050  2b 7d 2f 5d 7b 32 36 62  28 3b 36 35 66 2b 3a 63  |+}/]{26b(;65f+:c|
00000060  4e 7d 2f                                          |N}/|
00000063

Online demo.

The approach is difference-encoding in base-26.

\$\endgroup\$
  • \$\begingroup\$ Adding a character to an integer yields a character, so you can replace 65f+:c with 'Af+. \$\endgroup\$ – Dennis Aug 13 '15 at 22:30
  • \$\begingroup\$ True. And md is a brilliant improvement, but I hadn't realised how close my answer is to yours. \$\endgroup\$ – Peter Taylor Aug 14 '15 at 15:31
2
\$\begingroup\$

CJam, 100 98 bytes

'A'@" ©Ô&ñ±ð¨9_AÚá¼thÁätÑû¨HÙH&J3p¼ÛèVçckùá%´}xà41"260bGb{_{+N2$2$}{;;)'@}?}%-3<

(permalink)

  • Saved two bytes via preinitialized variables (thanks Dennis!)

This is my first CJam entry, so there is probably the potential for some more golfing. However, I came up with a way to compress the list of characters down to 63 bytes which, hopefully, someone else will find helpful.

Compression Method

So far most methods that I saw encoded both letters of each word. However, when we put the words in alphabetical order, the first letter doesn't change very often, so it seems wasteful to encode it explicitly.

I encode only the last character of each word, and include a special item whenever the first character should increment. The characters are encoded as the first character, then a list of differences. Since there are no duplicate words, the differences must all be at least 1. Thus I can use 0 as a separator item. (Note that I must then store the first letter of each subsequence as one-indexed, otherwise there would be confusion between 'rollover first character 0' and 'start with A 0'.)

Since the differences in this case are never greater than 15, we can use base-16 and pack two (4-bit) items into each (8-bit) byte. (In the actual code I converted from base-260 instead of base-256 to avoid issues with unprintable characters.)

\$\endgroup\$
  • \$\begingroup\$ You can save a couple of bytes by using G and N, which push 16 and a linefeed. \$\endgroup\$ – Dennis Aug 16 '15 at 0:21
  • \$\begingroup\$ @Dennis Thanks, didn't realize variables were preinitialized! \$\endgroup\$ – 2012rcampion Aug 16 '15 at 0:27
  • 1
    \$\begingroup\$ All 26 uppercase letters are preinitialized variables. You can see the complete list here. \$\endgroup\$ – Dennis Aug 16 '15 at 0:30
  • \$\begingroup\$ You can save more bytes by replacing %-3< with /;; or even /&. (The second option will generate an error message. Consensus on meta is that it's OK to do this.) \$\endgroup\$ – Dennis Aug 16 '15 at 5:00
2
\$\begingroup\$

brainfuck, 1371 bytes

Quite golfable, but I didn't put too much effort into it.

>+[+[<]>>+<+]>[-<<+<+>>>]-[-[-<]>>+<]>-[-<<<<+>>>>]<<<<<<..>>.<<.>+.>.<<.>++.>.<
<.>+.>.<<.>++.>.<<.>+.>.<<.>+.>.<<.>+++.>.<<.>+.>.<<.>+.>.<<.>++++.>.<<.>+.>.<<.
>+.>.<<.>+++.>.<<.>+.>.<<.>+.>.<------------------------<+.>.>.<<.>++++.>.<<.>++
++.>.<<.>++++++.>.<<.>++++++++++.>.<--------------------<++.>.>.<<.>++++++++++.>
.<-----------<+.>.>.<<.>++.>.<<.>++.>.<<.>++++.>.<<.>+.>.<<.>+.>.<<.>++++.>.<<.>
+.>.<<.>+.>.<<.>++++.>.<-----------------------<+.>.>.<<.>++++.>.<<+.>++++++++++
.>.<--------------<+.>.>.<<.>++++.>.<<.>++++.>.<<.>++++.>.<<.>++.>.<-----------<
+.>.>.<<.>++.>.<<.>++++++++.>.<<.>+++++.>.<<.>+.>.<-----<+.>.>.<--------------<+
.>.>.<<.>++++++++.>.<--------<+.>.>.<<.>++++++++.>.<<.>+.>.<---------<+.>.>.<<.>
++++.>.<<.>++++.>.<<.>++++.>.<<.>++.>.<<.>++++++.>.<<.>++++.>.<-----------------
-------<+.>.>.<<.>++++.>.<<.>++++++++++.>.<<.>++++++.>.<-----------------<+.>.>.
<<.>+.>.<<.>+.>.<<.>++.>.<<.>+.>.<<.>++++.>.<<.>+.>.<<.>++.>.<<.>++.>.<<.>+.>.<<
.>++++.>.<<.>+.>.<<.>+.>.<------------------------<+.>.>.<<.>++++.>.<<.>++++.>.<
<+.>.>.<----<+.>.>.<<+.>+++.>.<<.>+.>.<<.>++++++.>.<--------------<+.>.>.<<.>+++
+++++.>.<<.>++++++.>.<-------<+.>.>.<<.>+++++.>.<<.>+.>.<<.>++.>.<<.>+++.>.<<.>+
.>.<---------------<++.>.>.<<.>++++++++++.>.<------<+.>.>.<<.>++++++++++++.>.<--
------------------<+.>.>.<<.>++++.>.<<.>++++++++++.>.<--------------<+.>.>.

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Well for one thing, you can get rid of the newlines \$\endgroup\$ – Jo King Aug 25 at 11:30
  • \$\begingroup\$ @JoKing there is no real way I could outgolf someone, I don't think there is much sense in shaving off a couple of bytes on this big scale. \$\endgroup\$ – Krzysztof Szewczyk Aug 25 at 13:23
2
\$\begingroup\$

Zsh, 175 bytes

This solution uses a 125-char string, where the lowercase letters serve as delimiters and the first letter of the following sequence of capital letters.

We iterate over the letters of $L. If the current letter $X is lowercase by ascii comparison, set $W to $X. Otherwise, print $W concatenated with $X to make the current word.

Try it Online!

L=aABDEGHILMNRSTWXYbAEIOYdEOeDFHLMNRSTXfAEgOhAEIMOiDFNSTjOkAIlAIOmAEIMOUYnAEOUoDEFHIMNPRSWXYpAEIqIrEsHIOtAIOuHMNPSTwEOxIUyAEOzA
for X in ${(s::)L};{((#X>90))&&W=$X||<<<$W$X:l}

Edit: appended :l to set lowercase consistently, per requirement
Edit2: -4 bytes using $X variable and simplified if [[..]] condition
Edit3: -4 bytes by removing quotes (")
Edit5: -5 bytes using array conversion instead of iterating over L per below
Edit4: Alternate approach for 182 bytes, exploiting reversible strings in the first 33 letters, $L is only 107 letters

L=aBHLMNTYdEOeFHMNRhOiSTmOUnOUoSWYaADEGIRSWXbEIOYeLSTXfAgOhIMiDFNjOkAIlIOmIMYoEFIPRXpAEIqIsHtOuHPSTwExIUyEzA
for ((;i++<$#L;))X=$L[i]&&((#X>90))&&W=$X:u||<<<$W$X`((i<34))&&<<<\ $X$W`
\$\endgroup\$
2
\$\begingroup\$

Stax, 91 bytes

âG→æ£ilæα¿:√▒▓uøD¶[│█æä║¢v┼T↨σªΩ■&*φòb¡CÆ?ì▀┬6ù═╦±qBF!╘π╓╙'♣*ù&↕!£ä3±r⌡W-╓D╬☺╝ï╜²á5Æ÷§═ôφF;

Run and debug it

The only neat trick this answer uses is using the "," token to show a change in the first letter, rather than storing it for every word.

Thanks to recursive for the idea of using the m operator

\$\endgroup\$
  • \$\begingroup\$ Nicely done. There are a couple of small optimizations I can see. Use M instead of 1/, and use a shorthand map m instead of explicit foreach and print { ... PF. This one packs to 89. \$\endgroup\$ – recursive Aug 29 at 21:23
1
\$\begingroup\$

Python 3, 224 bytes

s='';i=int("AQHU9HU1X0313T1J9OMYMZZSRFWLCYT3POSE06UGHXDZN6H5SQSZIFCE6VEB",36)
for c in range(26):
 b=i%6;i//=6;k=(1<<b)-1;j=i%(1<<k);i>>=k
 for d in 'AOIEHMUSTMNDFPYBCGJKLQRVWXZ':
  if j&1:s+=chr(c+65)+d+' '
  j>>=1
print s

Uses bit masks of variable length to encode which second letters exist for each possible first letter. The bit masks can be 0,1,3,7,15 or 31 bits long. Bits are mapped to letters with for d in 'AOIEHMUSTMNDFPYBCGJKLQRVWXZ':, earlier bits are used for more common letters so that the bit masks can be short in most cases (usually 3 or 7 bits since most consonants are only followed by one of 5 vowels or Y M or H). Unfortunately the code to decode it negates the savings compared to more simple methods (the original list is only 303 bytes).

\$\endgroup\$
  • 1
    \$\begingroup\$ I discovered it's better to encode which first letter exists for each possible second letter in my solution. Might be worth trying in yours. \$\endgroup\$ – James Webster Aug 13 '15 at 15:08
1
\$\begingroup\$

Haskell, 192 bytes

putStr$(\(a:b)->((a:).(:" "))=<<b)=<<words"AABDEGHILMNRSTWXY BAEIOY DEO EDFHLMNRSTX FAE GO HAEIMO IDFNST JO KAI LAIO MAEIMOUY NAEOU ODEFHIMNPRSWXY PAEI QI RE SHIO TAIO UHMNPST WEO XIU YAEO ZA"

For every space separated word in the string put the first letter in front of all other letters and add a space, e.g SHIO -> SH SI SO.

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

Java, 334 bytes

public class C{public static void main(String[]a){for(int i=0;i<26;i++){for(int j=0;j<26;j++){if(java.util.BitSet.valueOf(java.util.Base64.getDecoder().decode("2znORQQBBAAAAAQQAKg4jkQAAAAABEBEFAAoIAwAAAEQEABAQBAAEVEQRQBBgBtrXEQAAAABAEAAAAAYBEBAEACAsAwAAAAAAQQAQAAEEUAABA==")).get(i*26+j)){System.out.format("%c%c\n",'a'+i,'a'+j);}}}}}

Formatted:

public class Code {
    public static void main(String[] a) {
        for (int i = 0; i < 26; i++) {
            for (int j = 0; j < 26; j++) {
                if (java.util.BitSet.valueOf(
                        java.util.Base64.getDecoder()
                            .decode("2znORQQBBAAAAAQQAKg4jkQAAAAABEBEFAAoIAwAAAEQEABAQBAAEVEQRQBBgBtrXEQAAAABAEAAAAAYBEBAEACAsAwAAAAAAQQAQAAEEUAABA=="))
                        .get(i * 26 + j)) {
                    System.out.format("%c%c\n", 'a' + i, 'a' + j);
                }
            }
        }
    }
}

Separately, I encoded the word list into a length 26x26=676 BitSet, converted it to a byte array, and then finally to Base 64. That string is hard-coded in this program, and the reverse procedure is used to reproduce the BitSet, and ultimately print out the list of words

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

Java, 356 bytes

Uses the random number generator to get the words:

import java.util.Random;class X{public static void main(String[]a){int j,n,m=9,x;for(String u:"rgzza 2u2hh r2rxs qs5f fwiag 26i33y 2xqmje 5h94v 16ld2a 17buv 4zvdi 1elb3y 2t108q 5wne9 1mrbfe 1ih89 fh9ts r0gh".split(" ")){x=Integer.parseInt(u,36);Random r=new Random(x/2);j=m-=x%2;while(j-->0){n=r.nextInt(676);System.out.format(" %c%c",65+n/26,65+n%26);}}}}

Ungolfed:

import java.util.Random;
class X{
    public static void main(String[]a){
        int j,n,m=9,x;
        for(String u:"rgzza 2u2hh r2rxs qs5f fwiag 26i33y 2xqmje 5h94v 16ld2a 17buv 4zvdi 1elb3y 2t108q 5wne9 1mrbfe 1ih89 fh9ts r0gh".split(" ")){
            x=Integer.parseInt(u,36);
            Random r=new Random(x/2);
            j=m-=x%2;
            while(j-->0){
                n=r.nextInt(676);
                System.out.format(" %c%c",65+n/26,65+n%26);
            }
        }
    }
}

You can try it here: http://ideone.com/Qni32q

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

Perl, 248 bytes

@v=split(//,"AEIOU");@s=split(' ',"ADEGIRSWX LSTX DFN EFIPRX HPST BHLMNTY DFHMNR ST DHMNSWY MN ZFKP WYPB KQXLHPMB LGJTB X");for(0..14){foreach $c(split(//,@s[$_])){$_<10?print @v[$_%5].$c." ":a;$_>4?print $c.@v[$_%5]." ":a;}}print "MM MY BY HM SH";

First time using perl (and first time golfing), so there's definitely room for improvement. Factored out the vowels and grouped the remaining letters based on how the resulting word was created - adding the vowel first, last, or both vowel first and last create a word on the list.

\$\endgroup\$
  • \$\begingroup\$ I don't know Perl, but I assume you are separating the output by spaces. It seems "MM "."MY "."BY "."HM "."SH " could be shortened to "MM MY BY HM SH". \$\endgroup\$ – Level River St Aug 14 '15 at 19:05
  • \$\begingroup\$ @steveverrill Thanks! I got so caught up in the rest of the code that I overlooked how redundant that was. \$\endgroup\$ – VoiceOfFolly Aug 14 '15 at 19:18
1
\$\begingroup\$

Javascript (ES6), 214

Perhaps not the shortest way to do it, but definitely interesting.

_=>(i=0,[...'ABDEFGHILMNOPRSTUWXY'].map(z=>[...`ABFHKLMNPTYZ
A
AEIO
ABDFHMNOPRWY
EIO
A
AEOSU
ABHKLMOPQSTX
AE
AEHMOU
AEIOU
BDGHJLMNSTWY
OU
AEO
AEIOU
AEIU
MNX
AO
AEO
ABMO`.split`
`[i++]].map(g=>g+z).join` `).join`
`)

Loops through each letter in the first string, adding it onto each letter in the corresponding line of the second. This returns the words in order of their last letter, like so:

AA BA FA HA KA LA MA NA PA TA YA ZA
AB
AD ED ID OD
AE BE DE FE HE ME NE OE PE RE WE YE
EF IF OF
AG
AH EH OH SH UH
AI BI HI KI LI MI OI PI QI SI TI XI
AL EL
AM EM HM MM OM UM
AN EN IN ON UN
BO DO GO HO JO LO MO NO SO TO WO YO
OP UP
AR ER OR
AS ES IS OS US
AT ET IT UT
MU NU XU
AW OW
AX EX OX
AY BY MY OY

Suggestions welcome!

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

Java, 255 254 bytes

Found a way to squeeze one more byte out of it.

class C{public static void main(String[]a){char c='A';for(char l:"ABDEGHILMNRSTWXY AEIOY  EO DFHLMNRSTX AE O AEIMO DFNST O AI AIO AEIMOUY AEOU DEFHIMNPRSWXY AEI I E HIO AIO HMNPST  EO IU AEO A".toCharArray())if(l<'A')c++;else System.out.print(" "+c+l);}}

Or (though not much clearer):

class C {
    public static void main(String[] a) {
        char c = 'A';
        for (char l : "ABDEGHILMNRSTWXY AEIOY  EO DFHLMNRSTX AE O AEIMO DFNST O AI AIO AEIMOUY AEOU DEFHIMNPRSWXY AEI I E HIO AIO HMNPST  EO IU AEO A"
                .toCharArray())
            if (l < 'A')
                c++;
            else
                System.out.print(" " + c + l);
    }
}
\$\endgroup\$
  • \$\begingroup\$ You can save two bytes by changing both occurrences of 'A' into 65. \$\endgroup\$ – ProgramFOX Aug 15 '15 at 12:31
1
\$\begingroup\$

Haskell, 333 308 298 bytes

Just for fun!

Evaluating s will print all of the words in a weird order - I used the fact that most combinations are vowel-consonant or vice versa, could probably optimize even more with custom character "classes", shortening the encoded matrix (here, w and k).

Does anybody know a shorter way to print strings without quotes and brackets than my monadic one? Type classes are even longer as far as I can tell.

Also, there might also be a shorter way of doing p's job...

v="AEIOU"
c="BCDFGHJKLMNPQRSTVWXYZ"
w=[976693,321324,50188,945708,52768]
k=[15,0,10,3,8,15,8,5,13,31,27,7,4,2,12,13,0,10,20,11,1]
z a b x=[[c:[e]|(e,f)<-b#p d,f]|(c,d)<-a#x]
(#)=zip
p 0=[]
p n=((n`mod`2)>0):p(n`div`2)
s=mapM_ putStrLn$concat$z v c w++z c v k++[words"AA AE AI BY HM MM MY OE OI SH"]
\$\endgroup\$
  • \$\begingroup\$ Isn't sequence_ the same as void$sequence? Then you can omit also the import. \$\endgroup\$ – nimi Aug 13 '15 at 22:40
  • \$\begingroup\$ That's oddly packaged, but yes. Thanks! \$\endgroup\$ – Leif Willerts Aug 13 '15 at 22:48
  • \$\begingroup\$ Isn't, void had to be imported. Anyways, gonna/gotta remember this. \$\endgroup\$ – Leif Willerts Aug 13 '15 at 22:52
  • 1
    \$\begingroup\$ Ah, and sequence_$map putStrLn is mapM_ putStrLn. Replace the (, ) around concat$... with another $. \$\endgroup\$ – nimi Aug 13 '15 at 23:07
1
\$\begingroup\$

05AB1E, 143 bytes (Non-compete)

•ZÐFý8ù6„=4ÅœÿWì±7Ë5Œ¾`ó/îAnµ%Ñ¥Ëø±/ÀéNzքѧIJ¶D—ÙVEStvÖò…¸¾6F³#EXŠm¯Cĵ±ÓoÊ°}^€Ftå߀ðŒ=«j;F-Â1;xX3i&QZÒ'Ü”>lwìlOs>íÙVÇI)~î‰Hç²?Öd0È^ÝQ°•36B2ô»

Try it online!

\$\endgroup\$
  • \$\begingroup\$ 95 bytes by porting @Sp3000's Python 3 answer. \$\endgroup\$ – Kevin Cruijssen Aug 30 at 7:16
  • 1
    \$\begingroup\$ @KevinCruijssen 91 (and I'm sure this method can get lower, but I hand-picked the dictionary words for humor). \$\endgroup\$ – Grimmy Aug 30 at 13:33
1
\$\begingroup\$

PHP, 170 bytes

shortest approach I could find so far ...

for(;$c=ABFHKLMNPTYZ1A2AEIO1ABDFHMNOPRWY1EIO1A1AEOSU1ABHKJMOPQSTX3AE1AEHMOU1AEIOU1BDGHJLMNSTWY1OU11AEO1AEIOU1AEIU1MNX2AO1AEO1ABMO[$i++];)$c<1?print$c.chr($k+65)._:$k+=$c;

breakdown

for(;$c=CHARACTERS[$i++];)  // loop $c through map
    $c<1                            // if $c is a letter (integer value < 1)
        ?print$c.chr($k+65)._           // print first letter, second letter, delimiter
        :$k+=$c                         // else increase second letter
    ;

Note The shortest bit-mapping version with printable ascii costs 190 bytes (113 bytes data+77 bytes decoding) using 6 bits=base 64, 174 bytes (97 data, 77 decoding) using 7 bits (base 128); possibly some more for escaping.

for(;$p<676;)                   // loop through combinations
    ord("MAPPING"[$p/6])-32>>$p%6&1     // test bit
        ?                                       // if set, do nothing
        :print chr($p/26+65).chr($p++%26+65)._; // if not, print combination+delimiter

Base 224 (using ascii 32..255) takes 87 bytes data (+ escaping); but I guess the decoding will cost more than 10 bytes extra.
Excluding C and V from the map would save 16/14/13 bytes on the data but cost a lot in decoding.

\$\endgroup\$

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.