Nice speedup!
using a 'lowered' word list gives:
6 {. ({~\:@:(#&.>)) (<'letterbrei') (*./@:>:"1&:lettfreq # ]) lowerwb
+--------+--------+--------+--------+--------+--------+
|bitterer|brittler|letterer|litterer|reletter|terrible|
+--------+--------+--------+--------+--------+--------+
3.224783 69194368
Or extending the alphabet with uppercases:
6 {. ({~\:@:(#&.>)) (<'letterbrei') (*./@:>:"1&:lettfreq # ]) wb
+--------+--------+--------+--------+--------+--------+
|bitterer|brittler|letterer|litterer|reletter|terrible|
+--------+--------+--------+--------+--------+--------+
ts '6 {. ({~\:@:(#&.>)) (<''letterbrei'') (*./@:>:"1&:lettfreq # ]) wb'
5.894405 136303168
=@@i
Henry Rich schreef:
> I don't have a dictionary to test with, but another approach is to
> count the number of letters in each dictionary word, and then keep
> only the dictionary words that can be made from the letters given. This
> would be something like:
>
> alphabet =: 'abcdefghijklmnopqrstuvwxyz'
> lettfreq =: alphabet&(+/@:="0 1)@>
> cullwb =: (<'letterbrei') (*./@:>:"1&:lettfreq # ]) wb
>
> the list of qualified words is in cullwb, and you can sort that as you like.
>
> This feels like it might be more economical especially for large
> starting words.
>
> Henry Rich
>
>
> Aai wrote:
>
>> Fished up from the blogosphere:
>>
>> >From a set of letters, say 'letterbrei', I want to produce a set of the
>> longest possible words (checked against a reference list). Reading about
>> symbol s: I decided to use this to make a lookup table of sorted words
>> from the imported word list. Here's my interpretation:
>>
>>
>> NB. word list
>> wb =: 'b' fread <'/usr/share/dict/words'
>>
>> # wb
>> 380645
>>
>>
>> NB. build a symbol table from the word list
>> wbs=: s: /:~&.> wb
>>
>> NB. lookup function
>> lu=: wb{ ~ [: I. wbs e. s:@<
>>
>> NB. powerset function, e.g.
>> ps=: (],,&.>)/@(a:,~,&.>)
>>
>> Example of use:
>>
>> NB. desc. sort by length unique subsets with minimum
>> length 3
>> ts '6 {. ({~\:@:(#&.>)) ; lu &.> (#~[:;2&<@#&.>) ~. ps /:~
>> ''letterbrei'''
>> 8.977938 639296
>> +--------+--------+--------+--------+--------+--------+
>> |litterer|letterer|reletter|brittler|bitterer|terrible|
>> +--------+--------+--------+--------+--------+--------+
>>
>>
>> Question is are there alternatives I should know of?
>>
>>
>> Thanks
>>
>> =@@i
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm