Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Using my /usr/share/words/dict I found 3 different 5 word "solutions". However I disagreed with the dictionary on whether pino and penk are really English words. (Or piro for that matter, but that was in the same line that used pino.) That left just one solution:

    ping
    pint
    pent
    pert
    perl

    I didn't bother to go through 6 word solutions - there are a lot of them.

    Here is the program that I wrote to find this:

    #! /usr/bin/perl
    use strict;
    use warnings;

    open(DICT, "/usr/share/dict/words") or die "Can't open words: $!";
    m

    • >

      The original Unix* usr/dict/words file was always skewed by Bell Labs terminology. The crossword fanciers' online dict files are usually better for word puzzles. Links to such at foot of my Boston.PM talk on Cheating at Word Puzzles with Perl http://world.std.com/~wdr/x/wesun/WESun.html [std.com] .
      I remember liking thzweb2 file, with web2a good for common phrase puzzles.

      Not that the larger dict matters for this puzzle since there is such a short ladder already, but 'words' having only qw(peal peel perk) as perl

      --
      Bill
      # I had a sig when sigs were cool
      use Sig;
      • Sensitive how? If perl is not in your dictionary, then reversing the two will result in your never finding perl. If there are multiple paths, reversing can change which path you find. Otherwise it should run forwards as well as backwards.

        It admittedly lacks when it comes to efficiency. However given that most of the time on my machine was scanning the file, I didn't care to optimize.

        • Even if Perl is in dict, starting at perl is faster since it has fewer adjacent ladder words, so search tree starts less bushy (and on average will reamain so), and more next-move-win states since ping has more adjacency.

          Most of the time shouldn't be in file scan unless your machine has no disk cache or the program ran correctly the first and only time! With cache, I am seeing 124ms on building %is_word with a small dict, twice as much loading half dozen dicts including moby. Oh wait, I made one small tweak to achieve that ...

          my $n = length($start ); # add ...
          while () {
                          chomp();
                          next unless length() == $n; # add
                          $is_word{lc($_)}++;
          }

          the cost of rebalancing the much smaller hash is much less. To build a full dict is more like 5000ms, so yes, tha would be dominating. Don't hash what you don't need!

          maybe tonight or weekend i can bench some otheralgos, eg the meet in the middle / alternate ends strategy and the grep f($word), keys tactic. Need something better to try to answer if there is ANY connection from
              ladder
              ramrod

          starting from ping, with a gob of dicts loaded, I still don't to theoretical 3-move 4-ladder, but this is cute -

          perl
          pern
          penn
          peng
          ping

          not that I'd allow many of those in a game of Scr@bbl3* either.

          --
          Bill
          # I had a sig when sigs were cool
          use Sig;