Print all 2 letter Scrabble Words

40

4

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

qwr

Posted 2015-08-13T03:22:07.067

Reputation: 8 929

8Do the words have to be outputted in the same order? – Sp3000 – 2015-08-13T03:26:46.577

2@Sp3000 I'll say no, if something interesting can be thought up – qwr – 2015-08-13T03:29:51.160

To avoid link rot, I've added your list to the question.Your list is the 2006 US list. The 2015 UK list contains significant differences, for example, it includes the words CH and ZO and has only very recently included ZA. I'm not clear what you mean by "something interesting." I think that means any order is acceptable, because you would be saying that some orders are arbitrarily acceptable and others not. – Level River St – 2015-08-13T05:34:05.140

1Would an at-sign be an acceptable separator? If the answer is yes, can I have a trailing at-sign? – Dennis – 2015-08-13T05:47:52.257

2Please clarify what exactly counts as separated somehow. Does it have to be whitespace? If so, would non-breaking spaces be allowed? – Dennis – 2015-08-13T14:14:04.820

1

Similar idea to http://codegolf.stackexchange.com/q/39787/29750

– NinjaBearMonkey – 2015-08-13T14:27:51.153

2Is there a site for looking up what these words mean? I've searched for "ZA" and ... short for Pizza. Really? I'd slap someone if they tried to use that "word" in scrabble – Mikey Mouse – 2015-08-13T15:11:38.317

5

Ok, found a translation

– Mikey Mouse – 2015-08-13T15:16:08.477

1Note that not only no word starts with C or V but no word really contain C or V. Maybe is useful for someone looking at bit optimization. – sergioFC – 2015-08-13T21:55:32.883

Vaguely related: http://codegolf.stackexchange.com/q/39787/15599

– Level River St – 2015-08-14T18:58:58.830

Is there a limit on running time, or can I proof that within a finite running time, a valid answer is given? – agtoever – 2015-08-15T08:48:19.643

3Vi isn't a word? News to me... – jmoreno – 2015-08-15T15:23:07.123

Answers

39

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.

Sp3000

Posted 2015-08-13T03:22:07.067

Reputation: 58 729

1+1 nice approach! I Borrowed your string for a Ruby answer – daniero – 2015-08-13T20:52:16.747

I also made an answer based on your idea using bash and regex – sergioFC – 2015-08-14T10:36:29.340

2+1 for AYAHOYOWOMUNUHAID! – Level River St – 2015-08-15T00:02:26.150

28

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.

Dennis

Posted 2015-08-13T03:22:07.067

Reputation: 196 637

14

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)." ":"";

James Webster

Posted 2015-08-13T03:22:07.067

Reputation: 2 809

Instead of exploding by ",", you can use explode(0,UB1YB0100CUP[...]) – Ismael Miguel – 2015-08-13T15:11:29.697

Wouldn't that break since there are 0s in the encoding? – James Webster – 2015-08-13T15:13:25.327

However.. there isn't a 3 I can use that! Thanks – James Webster – 2015-08-13T15:16:06.413

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^' '. – Ismael Miguel – 2015-08-13T15:41:27.000

Good catch! I wouldn't have got that one. – James Webster – 2015-08-13T15:43:34.193

I'm glad I've helped you. I'm trying to find what else to reduce – Ismael Miguel – 2015-08-13T15:50:51.807

8

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.

AKHolland

Posted 2015-08-13T03:22:07.067

Reputation: 181

I can't get this to work in an online compiler. – mbomb007 – 2015-08-14T20:00:07.347

@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. – AKHolland – 2015-08-15T12:45:37.573

7

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

griFlo

Posted 2015-08-13T03:22:07.067

Reputation: 171

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 :) – jrich – 2015-08-13T16:57:37.083

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. – James Webster – 2015-08-14T09:35:50.470

You've also missed a few spaces that you can remove. – James Webster – 2015-08-14T09:37:55.163

@JamesWebster thx for the hints. – griFlo – 2015-08-14T10:11:29.023

4"".format is painful to look at, but hilarious. – codebreaker – 2015-08-14T19:59:15.707

just figured out, I can save 2 characters by making the counter variable i an Integer and call the static toString(...) on i – griFlo – 2015-08-17T05:31:18.083

also String[] a gpt one unneeded whitespace, after []s you can shave em off – masterX244 – 2015-09-20T15:21:59.753

7

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

Level River St

Posted 2015-08-13T03:22:07.067

Reputation: 22 049

Maybe make a hexdump of the golfed version so the mangling can be reverted easily – masterX244 – 2015-09-20T15:23:21.057

6

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!

Krzysztof Szewczyk

Posted 2015-08-13T03:22:07.067

Reputation: 3 819

6

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}

daniero

Posted 2015-08-13T03:22:07.067

Reputation: 17 193

6

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)

Luis Mendo

Posted 2015-08-13T03:22:07.067

Reputation: 87 464

2Nice one Luis! Golfing is actually kind of fun... =P – Stewie Griffin – 2015-08-14T07:56:29.150

1Nice! There is no alphabet! – Brain Guider – 2015-08-14T09:07:36.570

1hats off. This is the most cryptic matlab code i've seen in ages ... – Hoki – 2015-08-14T15:32:09.347

Thanks guys! It's only cryptic because of the base-64 encoding. That string actually packs the 26x25 binary matrix of allowed letter pairs – Luis Mendo – 2015-08-14T21:31:29.630

5

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

sergioFC

Posted 2015-08-13T03:22:07.067

Reputation: 151

1

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.

– Adam Katz – 2017-01-23T19:28:53.670

5

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

Adam Katz

Posted 2015-08-13T03:22:07.067

Reputation: 306

3+1 for being practical. Really, providing the base echo is the point everyone should start from. – metalim – 2015-08-15T10:18:08.283

+1 on easy answer, but you should be marking that as non competing, shouldn't you? – Matthew Roh – 2017-01-24T01:32:53.547

@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. – Adam Katz – 2017-01-24T01:55:27.137

3

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)

ar4093

Posted 2015-08-13T03:22:07.067

Reputation: 531

3

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

Jodrell

Posted 2015-08-13T03:22:07.067

Reputation: 131

4This 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. – Jakube – 2015-08-13T13:56:23.820

@Jakube, is that better? – Jodrell – 2015-08-13T16:21:15.113

Yes, looks o.k. – Jakube – 2015-08-13T18:51:22.380

3

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

Jake

Posted 2015-08-13T03:22:07.067

Reputation: 31

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" – Level River St – 2015-08-14T19:30:45.433

2

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`

roblogic

Posted 2015-08-13T03:22:07.067

Reputation: 554

2

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

user89655

Posted 2015-08-13T03:22:07.067

Reputation: 31

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.

– recursive – 2019-08-29T21:23:30.503

2

brainfuck, 1371 bytes

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

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

Try it online!

Krzysztof Szewczyk

Posted 2015-08-13T03:22:07.067

Reputation: 3 819

Well for one thing, you can get rid of the newlines – Jo King – 2019-08-25T11:30:17.790

@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. – Krzysztof Szewczyk – 2019-08-25T13:23:36.983

2

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.

NickW

Posted 2015-08-13T03:22:07.067

Reputation: 21

2

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.

– Sp3000 – 2015-08-13T15:15:09.943

Good catch. I've updated my submission accordingly – NickW – 2015-08-13T15:23:55.537

I can't see why.. but this now just prints "A A A A A..." – James Webster – 2015-08-13T15:28:19.313

You've taken out the ! on the if.. you needed that. – James Webster – 2015-08-13T15:31:46.617

Right. I just noticed that. I was using ! delimiter earlier and I did a quick find-replace without considering what would happen first. – NickW – 2015-08-13T15:34:29.767

But there are plenty of places this can be reduced. $b=0 can be omitted completely, it doesn't need initialising. The parenthesis around $c=.. can be removed. – James Webster – 2015-08-13T15:35:22.257

I think the entire if.. echo could be in a ternary, but I'm yet to figure it out. And even then it might not be shorter. – James Webster – 2015-08-13T15:35:57.080

As far as I am aware, the if.. cannot be removed (php does not like an echo inside the ternary, and you can't echo the result of the ternary because $a will be echoed)

Additionally not explicitly setting b produces a "stack notice" warning which breaks the output. If that's fine, then it goes down to 204 or 205 I believe. I've updated my response to include your other suggestions, however – NickW – 2015-08-13T15:45:56.103

Yeah I haven't found a way to reduce the if without printing the $a++ When I tried it without the $b=0 I didn't get any warnings.. I'd say that counts. You can require specific set ups for your answer to work. – James Webster – 2015-08-13T15:52:36.853

I like this and @Jake's answer - it's a simple approach that has very little overhead. Good job :) – Sp3000 – 2015-08-13T15:53:53.293

2

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.

Peter Taylor

Posted 2015-08-13T03:22:07.067

Reputation: 41 901

Adding a character to an integer yields a character, so you can replace 65f+:c with 'Af+. – Dennis – 2015-08-13T22:30:29.013

True. And md is a brilliant improvement, but I hadn't realised how close my answer is to yours. – Peter Taylor – 2015-08-14T15:31:49.870

2

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.)

2012rcampion

Posted 2015-08-13T03:22:07.067

Reputation: 1 319

You can save a couple of bytes by using G and N, which push 16 and a linefeed. – Dennis – 2015-08-16T00:21:17.217

@Dennis Thanks, didn't realize variables were preinitialized! – 2012rcampion – 2015-08-16T00:27:44.920

1

All 26 uppercase letters are preinitialized variables. You can see the complete list here.

– Dennis – 2015-08-16T00:30:06.067

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.)

– Dennis – 2015-08-16T05:00:57.250

1

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!

Magic Octopus Urn

Posted 2015-08-13T03:22:07.067

Reputation: 19 422

95 bytes by porting @Sp3000's Python 3 answer. – Kevin Cruijssen – 2019-08-30T07:16:46.483

1

@KevinCruijssen 91 (and I'm sure this method can get lower, but I hand-picked the dictionary words for humor).

– Grimmy – 2019-08-30T13:33:20.247

1

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.

Titus

Posted 2015-08-13T03:22:07.067

Reputation: 13 814

1

Python 2, 202 200 bytes

for s in'AABALIFEN KITOELOPE LAYAINUNEREMI AMANAHI MOHMYEX UPI UTAGOFAWOWETI BY OR BI ZAXI PAS BE AD AEDEHAT QI UMMUS JOIDONOSHOYOD BOMESISOXUHEF KAR'.split():
 for i in range(len(s)-1):print s[i:i+2]

Try it online!

Try to join up overlapping pairs; i.e. ZAXI encodes ZA, AX, XI. Looks like 140 bytes of encoded text is about the best possible with this approach.

Chas Brown

Posted 2015-08-13T03:22:07.067

Reputation: 8 959

140 bytes is the theoretical limit for this approach. – Joel – 2019-08-30T02:43:57.117

1

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).

samgak

Posted 2015-08-13T03:22:07.067

Reputation: 1 577

1I discovered it's better to encode which first letter exists for each possible second letter in my solution. Might be worth trying in yours. – James Webster – 2015-08-13T15:08:32.870

1

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

Leif Willerts

Posted 2015-08-13T03:22:07.067

Reputation: 1 060

Isn't sequence_ the same as void$sequence? Then you can omit also the import. – nimi – 2015-08-13T22:40:52.840

That's oddly packaged, but yes. Thanks! – Leif Willerts – 2015-08-13T22:48:56.200

Isn't, void had to be imported. Anyways, gonna/gotta remember this. – Leif Willerts – 2015-08-13T22:52:16.970

1Ah, and sequence_$map putStrLn is mapM_ putStrLn. Replace the (, ) around concat$... with another $. – nimi – 2015-08-13T23:07:26.660

1

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.

nimi

Posted 2015-08-13T03:22:07.067

Reputation: 34 639

1

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

Kevin K

Posted 2015-08-13T03:22:07.067

Reputation: 141

1

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

Arnaud

Posted 2015-08-13T03:22:07.067

Reputation: 8 231

1

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.

VoiceOfFolly

Posted 2015-08-13T03:22:07.067

Reputation: 11

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". – Level River St – 2015-08-14T19:05:32.577

@steveverrill Thanks! I got so caught up in the rest of the code that I overlooked how redundant that was. – VoiceOfFolly – 2015-08-14T19:18:59.710

1

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!

ETHproductions

Posted 2015-08-13T03:22:07.067

Reputation: 47 880

1

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

Aofl

Posted 2015-08-13T03:22:07.067

Reputation: 11

You can save two bytes by changing both occurrences of 'A' into 65. – ProgramFOX – 2015-08-15T12:31:23.047

0

Python 3, 248 bytes

e=enumerate
[print(*(chr(x+65)+chr(j+65)+" "for j,i in e(bin(k)[2:])if int(i)))for x,k in e([30292443,16793873,0,16400,9320616,17,16384,20753,794664,16384,257,16641,17846545,1064977,29798840,273,256,16,16768,16641, 831616,0,16400,1048832,16401,1])]

The numbers were generated by an additional script
I'm sure that it can be optimized further

ovs

Posted 2015-08-13T03:22:07.067

Reputation: 21 408

0

Retina, 167 bytes (non-competing)


¶AABDEGHIcWXY¶BbOY¶DEaEDFHcX¶FAE¶GaHbMaIDFNST¶JaKAI¶LAIaMbMOUY¶NAEOU¶ODEFHIMNPRSWXY¶Pb¶QI¶RE¶SHIaTAIaUHMNPST¶WEaXIU¶YAEaZA
c
LMNRST
b
AEI
a
O¶
+`(¶(.)\S+)(\S)
$1 $2$3

Try it online!

ovs

Posted 2015-08-13T03:22:07.067

Reputation: 21 408

0

C# (Visual C# Interactive Compiler), 208 bytes

()=>"ABDEGHILMNRSTWXY,AEIOY,EO,DFHLMNRSTX,AE,O,AEIMO,DFNST,O,AI,AIO,AEIMOUY,AEOU,DEFHIMNPRSWXY,AEI,I,E,HIO,AIO,HMNPST,EO,IU,AEO,A".Split(',').SelectMany((x,y)=>x.Select(z=>""+"ABDEFGHIJKLMNOPQRSTUWXYZ"[y]+z))

Try it online!

Innat3

Posted 2015-08-13T03:22:07.067

Reputation: 791

0

PHP, 187 bytes

for($n=A,$l=ABDEGHILMNRSTWXYAEIOY1EODFHLMNRSTXAEGOAEIMODFNS2TOAIAIOAEIMOUYAEOUDEFFHIMNPRSWXYAEI3IE4HIOAIOHMNPST5EOIUAEOA;$q=$l[$x++];){if($q<A)$n++;else{if($q<$p)$n++;$p=$q;echo"$n$q
";}}

Try it online!

Basically, the list is mostly just the second letters in the word list - I noticed in almost all cases, when incrementing the first letter, the second letter is before the one before it. For example going from AY to BA, A is before Y in the alphabet, and going from QI to RE, E is before I in the alphabet. In the very few cases where the second letter was the same or after the previous one, or to skip C and V, I put a number in the string so it knows to increment the first letter.

XMark

Posted 2015-08-13T03:22:07.067

Reputation: 141

0

F#, 205 bytes

Seq.iteri(fun i s->Seq.iter(printf"%c%c "((char)i+'A'))s;printfn"")("ABDEGHILMNRSTWXY AEIOY  EO DFHLMNRSTX AE O AEIMO DFNST O AI AIO AEIMOUY AEOU DEFHIMNPRSWXY AEI I E HIO AIO HMNPST  EO IU AEO A".Split())

Live version.

mattnewport

Posted 2015-08-13T03:22:07.067

Reputation: 1 579

0

scala, 223 bytes

print(("AABDEGHILMNRSTWXY BAEIOY DEO EDFHLMNRSTX FAE GO HAEIMO IDFNST JO KAI LAIO MAEIMOUY NAEOU ODEFHIMNPRSWXY PAEI QI RE SHIO TAIO UHMNPST WEO XIU YAEO ZA".split(" ").flatMap(a=>a.tail.map(a(0).toString+_))).mkString(" "))

Not especially compact, but vaguely idiomatic .. eval with

scala -e '...'

user2378682

Posted 2015-08-13T03:22:07.067

Reputation: 1

0

Python 239 bytes

import re;f=lambdax:''.join(re.findall('..',x));a,b='ABAHALAMANATAYDEDOEFEHEMENERHOISITMOMUNONUOSOWOY','AAADAEAGAIARASAWAXBEBIBOBYELESETEXFAGOHIHMIDIFINJOKAKILILOMIMMMYOEOFOIOPOROXPAPEPIQISHTOUHUPUSUTWEXIXUYEZA';print f(a),f(a[::-1]),f(b)

This is a bit long, but I've given it a try. I've counted all the patterns that also have the reversed counterparts. Ex) 'AB'/'BA' and so on.

handrake

Posted 2015-08-13T03:22:07.067

Reputation: 11

0

Java, 288

class E{public static void main(String[]a){a="ABDEGHILMNRSTWXY,AEIOY,,EO,DFHLMNRSTX,AE,O,AEIMO,DFNST,O,AI,AIO,AEIMOUY,AEOU,DEFHIMNPRSWXY,AEI,I,E,HIO,AIO,HMNPST,,EO,IU,AEO,A".split(",");for(int i=26,j;i-->0;)for(j=0;j<a[i].length();)System.out.println((char)('A'+i)+""+a[i].charAt(j++));}}

By just stringing together the second letters of each word (plus a delimiter), you just loop through while keeping track of the first. Not as fancy as the base-encoded versions, but much simpler and a good score for Java. Prints in order by descending-first-letter (ZA YA YE YO XI XU), one word per line.

With line breaks:

class E{
    public static void main(String[]a){
        a="ABDEGHILMNRSTWXY,AEIOY,,EO,DFHLMNRSTX,AE,O,AEIMO,DFNST,O,AI,AIO,AEIMOUY,AEOU,DEFHIMNPRSWXY,AEI,I,E,HIO,AIO,HMNPST,,EO,IU,AEO,A".split(",");
        for(int i=26,j;i-->0;)
            for(j=0;j<a[i].length();)
                System.out.println((char)('A'+i)+""+a[i].charAt(j++));
    }
}

Geobits

Posted 2015-08-13T03:22:07.067

Reputation: 19 061