On holidays, my family likes to play Boggle. The problem is that I'm terrible at Boggle. Therefore, I did what any good programmer could do: wrote a program for me.
The algorithm is based on a simple trie prefix , where each node is a dictreference to the following letters.
This is the implementation trie:add:
add ([], Trie) ->
dict: store (stop, true, Trie);
add ([Ch | Rest], Trie) ->
% setdefault (Key, Default, Dict) ->
% case dict: find (Key, Dict) of
% {ok, Val} -> {Dict, Val}
% error -> {dict: new (), Default}
% end.
{NewTrie, SubTrie} = setdefault (Ch, dict: new (), Trie),
NewSubTrie = add (Rest, SubTrie),
dict: store (Ch, NewSubTrie, NewTrie)., , (), :
http://gist.github.com/263513
, Erlang, , , , - ... , 800 .
, - ? ?