Update: Made to work with /usr/share/dict/words which contains uppercase words.

Well, I went and wrote the code to check against the dictionary.

use strict; use warnings; use Algorithm::Loops qw( NextPermute ); sub get_next_dict_word { my ($dict_fh) = @_; for (;;) { local $_ = <$dict_fh>; return $_ unless defined; my $first_letter = substr($_, 0, 1); return $_ if lc($first_letter) eq $first_letter; } } { die("Specify the word as an argument.$/") unless @ARGV; my $word = lc($ARGV[0]); # DICTIONARY MUST BE SORTED, ONE WORD PER LINE. # UPPERCASE WORDS ARE IGNORED. my $dict_fh; open($dict_fh, '<', '/usr/share/dict/words') or die("Can't open dictionary: $!$/"); my $dict_word = <$dict_fh>; chomp($dict_word) if defined $dict_word; my @list = sort ' ', $word =~ /(.)/g; my $last_permute = ''; while (NextPermute(@list)) { my $permute = join('', @list); $permute =~ s/ .*//; next if ($permute eq $last_permute); $last_permute = $permute; while (defined($dict_word) && $dict_word lt $permute) { $dict_word = <$dict_fh>; chomp($dict_word) if defined $dict_word; } if (defined($dict_word) && $permute eq $dict_word) { print("Found $permute$/"); $dict_word = <$dict_fh>; chomp($dict_word) if defined $dict_word; } else { print("Didn't find $permute$/"); } } } dictionary used --------------- apple dud dude dudette due orange output ------ Didn't find d Didn't find dd Didn't find dde Didn't find ddeu Didn't find ddu Didn't find ddue Didn't find de Didn't find ded Didn't find dedu Didn't find deu Didn't find deud Didn't find du Found dud Found dude Found due Didn't find dued Didn't find e Didn't find ed Didn't find edd Didn't find eddu Didn't find edu Didn't find edud Didn't find eu Didn't find eud Didn't find eudd Didn't find u Didn't find ud Didn't find udd Didn't find udde Didn't find ude Didn't find uded Didn't find ue Didn't find ued Didn't find uedd

In reply to Re^2: (un)jumbler... by ikegami
in thread (un)jumbler... by stevenrh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.