This progarm has been running for many years, over 20 I think.While
I do not watch it on a regular basis, I have watched it quite a
bit.
The rules are you can only use the letters given and you can only
use them as many times as they appear on the board.
Given that I dont think any solution so far actually solve the
problem correctly. Also the question was to only list those which
are of the longest length.
Here is my solution of 112
my @letters = qw(d u n s c a e y t);
open(D,"/usr/share/dict/words") or die $!;
print f(@letters);
sub f {
# 1 2 3 4 5
#234567890123456789012345678901234567890123456789012345
my%h;$h{$_}++for@_;my@b;push @{$b[length]},$_ for grep{
# 6 7 8 9 0 1
#78901234567890123456789012345678901234567890123456789012
my%g=%h;$g{$_}--for/./g;!grep{$_<0}values%g}<D>;@{$b[-1]}
}
But I am sure someone will shorten it
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|