[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Weekend Edition Sunday Puzzle (from c.l.p.mod)



>From: Vicki Brown <vlb@cfcl.com>

> Here's the puzzle:
> 
>    Take the 9-letter-word SUBDEACON (the name of a church official).
>    The word contains the first 5 letters of the alphabet, ABCD and E
>    consecutively inside it, although not in alphabetical order. This
>    is a two-part challenge: first, can you think of a common 8-letter
>    word that has ABCDE consecutively inside it, not necessarily in
>    alphabetical order; second, can you think of a common 7-letter word
>    with the same property? Both answers are uncapitalized words that
>    are familiar to everyone.
>
>    (C) 1999 Will Shortz
>
>
> Solutions in Perl are running over there. Here's the puzzle in case anyone
> wants to play here, or isn't on c.l.p.mod or...


I seen that; I had a submission, but never submitted it.
If you run the below, you'll see why:

#!/usr/local/bin/perl -wT

use strict;
use diagnostics -verbose;

my $len = -1;

open WORDS, "words" or die "No words file: $!";

while (<WORDS>) {
 chomp;              # no newline...
            s/#.*//; # no comments...
           s/^\s+//; # no leading whitespace...
           s/\s+$//; # no trailing whitespace...
 next unless length; # anything to process?

 print "\nInside of $_, I found ";

 while (++$len <= length($_)) {
      print substr($_, $len, 1)
          if (index("abcdefghijklmnopqrstuvwxyz",
                     substr($_ , $len, 1)) > -1);
  }

$len = -1;
}

# What did I find?
#
# I found yet another LONG way to split up
# words into individual characters...
#
# Not yet sure if that is good or bad...

Thx,
-Sneex-  :]
____________________________________________________________________
Bill Jones * Data Security Specialist * http://jacksonville.pm.org/
FCCJ * 501 W State St * Jacksonville, FL 32202 * 1 (904) 632-3089
    __ __                      __ __         __
   / // /__ ____  ___  __ __  / // /__ _____/ /_____ ____
  / _  / _ `/ _ \/ _ \/ // / / _  / _ `/ __/  '_/ -_) __/
 /_//_/\_,_/ .__/ .__/\_, / /_//_/\_,_/\__/_/\_\\__/_/
          /_/  /_/   /___/
         Running LinuxPPC RedHat 5.0 (Hurricane)
       __ _                     http://www.linuxppc.org
      / /(_)_ __  _   ___  __   http://www.apache.org
     / / | | '_ \| | | \ \/ /   http://www.redhat.com
    / /__| | | | | |_| |>  <    http://www.perl.com
    \____/_|_| |_|\__,_/_/\_\   http://www.gimp.org

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe