43
\$\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\$
13
  • 9
    \$\begingroup\$ Do the words have to be outputted in the same order? \$\endgroup\$
    – Sp3000
    Commented Aug 13, 2015 at 3:26
  • 2
    \$\begingroup\$ @Sp3000 I'll say no, if something interesting can be thought up \$\endgroup\$
    – qwr
    Commented Aug 13, 2015 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
    Commented Aug 13, 2015 at 14:14
  • 5
    \$\begingroup\$ Ok, found a translation \$\endgroup\$ Commented Aug 13, 2015 at 15:16
  • 3
    \$\begingroup\$ Vi isn't a word? News to me... \$\endgroup\$
    – jmoreno
    Commented Aug 15, 2015 at 15:23

49 Answers 49

40
\$\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\$
3
  • 1
    \$\begingroup\$ +1 nice approach! I Borrowed your string for a Ruby answer \$\endgroup\$
    – daniero
    Commented Aug 13, 2015 at 20:52
  • \$\begingroup\$ I also made an answer based on your idea using bash and regex \$\endgroup\$
    – sergioFC
    Commented Aug 14, 2015 at 10:36
  • 2
    \$\begingroup\$ +1 for AYAHOYOWOMUNUHAID! \$\endgroup\$ Commented Aug 15, 2015 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\$
16
\$\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\$
6
  • \$\begingroup\$ Instead of exploding by ",", you can use explode(0,UB1YB0100CUP[...]) \$\endgroup\$ Commented Aug 13, 2015 at 15:11
  • \$\begingroup\$ Wouldn't that break since there are 0s in the encoding? \$\endgroup\$ Commented Aug 13, 2015 at 15:13
  • \$\begingroup\$ However.. there isn't a 3 I can use that! Thanks \$\endgroup\$ Commented Aug 13, 2015 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\$ Commented Aug 13, 2015 at 15:41
  • \$\begingroup\$ Good catch! I wouldn't have got that one. \$\endgroup\$ Commented Aug 13, 2015 at 15:43
9
\$\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\$
9
\$\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\$
2
  • \$\begingroup\$ I can't get this to work in an online compiler. \$\endgroup\$
    – mbomb007
    Commented Aug 14, 2015 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
    Commented Aug 15, 2015 at 12:45
8
\$\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\$
1
  • \$\begingroup\$ Maybe make a hexdump of the golfed version so the mangling can be reverted easily \$\endgroup\$
    – masterX244
    Commented Sep 20, 2015 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\$
7
  • \$\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
    Commented Aug 13, 2015 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\$ Commented Aug 14, 2015 at 9:35
  • \$\begingroup\$ You've also missed a few spaces that you can remove. \$\endgroup\$ Commented Aug 14, 2015 at 9:37
  • \$\begingroup\$ @JamesWebster thx for the hints. \$\endgroup\$
    – griFlo
    Commented Aug 14, 2015 at 10:11
  • 4
    \$\begingroup\$ "".format is painful to look at, but hilarious. \$\endgroup\$ Commented Aug 14, 2015 at 19:59
7
\$\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\$
0
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\$
4
  • 2
    \$\begingroup\$ Nice one Luis! Golfing is actually kind of fun... =P \$\endgroup\$ Commented Aug 14, 2015 at 7:56
  • 1
    \$\begingroup\$ Nice! There is no alphabet! \$\endgroup\$ Commented Aug 14, 2015 at 9:07
  • 1
    \$\begingroup\$ hats off. This is the most cryptic matlab code i've seen in ages ... \$\endgroup\$
    – Hoki
    Commented Aug 14, 2015 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
    Commented Aug 14, 2015 at 21:31
6
\$\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
  • 3
    \$\begingroup\$ +1 for being practical. Really, providing the base echo is the point everyone should start from. \$\endgroup\$
    – metalim
    Commented Aug 15, 2015 at 10:18
  • \$\begingroup\$ +1 on easy answer, but you should be marking that as non competing, shouldn't you? \$\endgroup\$ Commented Jan 24, 2017 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
    Commented Jan 24, 2017 at 1:55
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
  • 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
    Commented Jan 23, 2017 at 19:28
5
\$\begingroup\$

Zsh --braceccl, 163 bytes

s=(ABDEGHILMNRSTWXY AEIOY EO DFHLMNRSTX AE O AEIMO DFNST O AI AIO AEIMOUY AEOU DEFHIMNPRSWXY AEI I E HIO AIO HMNPST EO IU AEO A)
for c ({ABD-UW-Z})echo $c{$s[++i]}

Try it Online!

Previously: 169 bytes , 175 bytes , 182 bytes

\$\endgroup\$
1
4
\$\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\$
4
  • \$\begingroup\$ You can save a couple of bytes by using G and N, which push 16 and a linefeed. \$\endgroup\$
    – Dennis
    Commented Aug 16, 2015 at 0:21
  • \$\begingroup\$ @Dennis Thanks, didn't realize variables were preinitialized! \$\endgroup\$ Commented Aug 16, 2015 at 0:27
  • 1
    \$\begingroup\$ All 26 uppercase letters are preinitialized variables. You can see the complete list here. \$\endgroup\$
    – Dennis
    Commented Aug 16, 2015 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
    Commented Aug 16, 2015 at 5:00
4
\$\begingroup\$

Python 3, 148 bytes

a=97
for n in b"!B$E'Hil-Nr3TWx9aEio9eodfHl-Nr3TxaEOaEi-odfN3TOaiaioaEi-ou9aEoudEfHi-N0r3Wx9aEiI%(ioaio(-N03TeoIuaEoa":a+=n%3;print("%c%c"%(a,n|96))

Try it online!

Prints lowercase.

The idea is to encode, for each of the 101 two-letter Scrabble words in order:

  • Whether the first letter is 0, 1, or 2 positions higher than the previous word's (3 options)
  • The second letter (26 options)

The 78 potential values fit easily in one byte per each entry n, and moreover within printable 7-bit ASCII.

The second letter is encoded in the last five bits, which lets the expression 96|n set the first two bits to ones to get its lowercase ASCII value. The first letter delta (0, 1, or 2) could be encoded in the first two bits, but it's golfier to extract it as n%3 by setting those two bits to whichever of 01, 10, or 11 gives the right value. Avoiding 00 let us avoid hitting unprintable characters in the range 0 to 31.

This answer uses 101 bytes for the hardcode data string and the other 47 bytes for extraction logic, so it's over 2/3 data. The data can surely be compressed further, but of course at a tradeoff to extraction.

Thanks to mousetail for posting a Python answer whose incremental-delta technique inspired this one.

\$\endgroup\$
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\$
1
  • \$\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\$ Commented Aug 14, 2015 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\$
3
  • 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
    Commented Aug 13, 2015 at 13:56
  • \$\begingroup\$ @Jakube, is that better? \$\endgroup\$
    – Jodrell
    Commented Aug 13, 2015 at 16:21
  • \$\begingroup\$ Yes, looks o.k. \$\endgroup\$
    – Jakube
    Commented Aug 13, 2015 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\$
3
\$\begingroup\$

Python, 174 158 bytes

-16 bytes thanks to @xnor

a=0
for x in b"BCBCBBDBBEBBDBBDEEGKcKQCCEBBEBBEEEfNEEECQCIFBWNITIGNEEECGEDEKGKBBCBEBCCBEBBDEE\X_BGNIGUFBCDBhKVMHEKN_":print('%c%c'%(a//27+65,a%27+65));a+=x-65

Attempt This Online!

String encodes the difference between each successive word. To find the word we need to sum all the letters then divmod 27. I beleive this is the shortest python answer so far.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Neat approach! Down to 158 bytes \$\endgroup\$
    – xnor
    Commented Sep 20, 2022 at 8:34
3
\$\begingroup\$

Python 3, 169 bytes

p,a="z",96
for i in "abdeghilmnrstwxyaeioy!!eodfhlmnrstxae!oaeimodfnstoaiaioaeimouyaeoudefhimnprswxyaeiie!hioaiohmnpst!!eoiuaeoa":print((chr(a:=a+(i<=p))+i)*(i>"_"));p=i

My first code golf. Uses a list of the second letter for each combination alphabetically, and changes the first letter if the next character is smaller than the previous (new set of words). Exclamation points are added to break up sections where the next character would be larger than the previous and to skip C and V.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$
    – rydwolf
    Commented Aug 31, 2023 at 3:20
  • \$\begingroup\$ 163 bytes, moving the logic outside the print and using operator chaining to make it happen conditionally. \$\endgroup\$
    – xnor
    Commented Aug 31, 2023 at 3:30
  • \$\begingroup\$ You can save a byte with the initial condition p,a="",97. Python 2 would allow p=a=97, but Python 3 isn't as permissive in comparing objects of different types. \$\endgroup\$
    – xnor
    Commented Aug 31, 2023 at 3:38
2
\$\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
  • 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\$ Commented Aug 13, 2015 at 15:08
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\$
10
  • 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
    Commented Aug 13, 2015 at 15:15
  • \$\begingroup\$ Good catch. I've updated my submission accordingly \$\endgroup\$
    – NickW
    Commented Aug 13, 2015 at 15:23
  • \$\begingroup\$ I can't see why.. but this now just prints "A A A A A..." \$\endgroup\$ Commented Aug 13, 2015 at 15:28
  • \$\begingroup\$ You've taken out the ! on the if.. you needed that. \$\endgroup\$ Commented Aug 13, 2015 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
    Commented Aug 13, 2015 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\$
2
  • \$\begingroup\$ Adding a character to an integer yields a character, so you can replace 65f+:c with 'Af+. \$\endgroup\$
    – Dennis
    Commented Aug 13, 2015 at 22:30
  • \$\begingroup\$ True. And md is a brilliant improvement, but I hadn't realised how close my answer is to yours. \$\endgroup\$ Commented Aug 14, 2015 at 15:31
2
\$\begingroup\$

brainfuck, 1371 bytes

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

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

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Well for one thing, you can get rid of the newlines \$\endgroup\$
    – Jo King
    Commented Aug 25, 2019 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\$ Commented Aug 25, 2019 at 13:23
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\$
1
  • \$\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
    Commented Aug 29, 2019 at 21:23
2
\$\begingroup\$

Vyxal, 78 bytes

kaf»⌐±ẋ∆ṡẊ⊍¬5=↔ε{→₇-¥Kkṡw¹ǔ„L²Fŀwɖ"≠₌Ǎ›ꜝ%ǐ[Q∑)fĠλ=WτṪṫ¨≤‹r≬|{gǔs⁼∵2»16τ0€v¦øA+

Try it Online!

This uses a strategy similar to the CJam answer of storing differences between the second letters and signalling a new first letter with a 0.

   »...»           # Large integer
        16τ        # Convert from base 16
           0€      # Split on zeroes
             v¦    # Take the cumulative sums of each list of numbers
               øA  # For each each number, get the nth letter
                 + # Prepend each of corresponding items of...
kaf                # The lowercase alphabet, as a list of characters
\$\endgroup\$
2
\$\begingroup\$

Regenerate -a, 148 bytes

A[BDGHLMNRSTWXY]|E[DFHLMNRSTX]|I[DFNST]|O[DFHIMNPRSWXY]|U[HMNPST]|[ABFHK-NPTYZ]A|[ABDFHM-PRWY]E|[ABHKLMPQSTX]I|[BDGHJLMNSTWY]O|[BM]Y|[HM]M|[MNX]U|SH

Attempt This Online!

Or

BY|HM|SH|NU|XU|A[BDGHLMNRSTWXY]|E[DFHLMNRSTX]|I[DFNST]|M[MUY]|O[DFHIMNPRSWXY]|U[HMNPST]|[ABFHK-NPTYZ]A|[ABDFHM-PRWY]E|[ABHKLMPQSTX]I|[BDGHJLMNSTWY]O

Attempt This Online!

I'm under the impression this is close to optimal, but I plan on writing a program to verify / discover the shortest solution which uses only this strategy. What I have here is as far as I could manage by hand.

Not a full code breakdown but everything here is basically just

XY|X[YZ]|[XY]Z

XY             // print XY
  |            // then
   X[YZ]       // print XY and XZ
        |      // then
         [XY]Z // print XZ and YZ
\$\endgroup\$
2
\$\begingroup\$

R, 199 198 bytes

In 2018 six new two-letter words were added to the Official Scrabble Players' Dictionary: DA, EW, GI, OK, PO, and TE. This answer would have had 192 bytes in 2015 but I wanted to include the new words!

`/`=strsplit;cat(unlist(Map(paste0,LETTERS[-22][-3],el('ABDEGHILMNRSTWXY,AEIOY,AEO,DFHLMNRSTWX,AE,IO,AEIMO,DFNST,O,AI,AIO,AEIMOUY,AEOU,DEFHIKMNPRSWXY,AEIO,I,E,HIO,AEIO,HMNPST,EOI,U,AEO,A'/',')/'')))

This answer is adapted from my answer at this related challenge about element names. First we overload the / operator with the strsplit() function. Then for the first letters of the words, we use the builtin LETTERS to get a vector of uppercase letters, removing elements 3 and 22 (C and V). For the second letters, we split a string by the , character to get a list of the second letters going with each first letter. Then we split it again by an empty string to get a list of vectors of individual characters. Map() is used to apply paste0() to the first elements of the first-letters vector and the second-letters list, then the second elements, etc. unlist() flattens and cat() prints without any quotes.

Attempt this online!

\$\endgroup\$
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\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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