Friday, January 21, 2011

Prying

We are having new closets fitted in a couple of weeks, so my job is to get the stuff out of the closets so that the new shelving, hangers etc. can go in. This not only means what's in there now, but also the fixtures. I unscrewed a bundle of wire shelves from the closets in my office. There was also some bits of wood nailed to the drywall, to support wooden shelves and so on. How do I get them out?

After trawling the web for ideas (and some tries with a flat-head screwdriver that made a mess of the drywall), I landed upon:
  • score around the edge of the wood with a craft knife (so as to make less of a mess of the paint, though I'm going to paint again anyway).
  • use a flat-head screwdriver to pull the wood a little away from the wall, being careful to do this far from the nails where it's easier
  • when the gap is wide enough, ease the claw of a hammer into the gap, and try to make the gap a little bigger.
  • Put a "shim" (small piece of wood, or, in my case, a nice thin but solid coaster advertising McVities Digestives) under where the hammer would go into the wall, and use the hammer claw to push the wood away from the wall, nails and all.
Having gotten all the wood off the wall in my office closet, I then tackled Megan's closet. It took me about 10 minutes, most of which time was spent finding a place to put the stuff that was in there already. The actual prying part was pretty quick.

The remaining closets are Amy's office (full of stuff, but otherwise just like Megan's), our closet (bigger, with a plastic hanging bar rather crudely screwed to the shelf), and the hall closet downstairs, which has a wood platform on the floor.

Oh, and I also rigged up something that would keep the mudroom door closed, involving the old door catch, a spare piece of wood, some nails (for the spare piece of wood) and a judicious arrangement of screws to fix the old door catch to the door jamb, and to hold it away from the jamb so I didn't have to try and chisel out a hole. (It's probably a temporary arrangement only, since I didn't hang the door properly in the first place, and, besides, the door is too small for the hole.)

I'm quite pleased with myself. Now I have to figure out something for dinner, including for Nathan, who doesn't eat much, especially if I cook it.

Thursday, January 13, 2011

how to cheat at scrabble

One of the things that grieves me about playing scrabble is "I wonder
if I missed a bingo?", particularly if I have a bunch of
likely-looking letters (or a blank). I did some searching, finding a
Perl one-liner (I like Perl) that searched a dictionary (like the Unix
/usr/dict/words) using regular expressions. But that didn't work when
I had multiples of a single letter, since regular expressions (without
some tweaking) don't help you count *how many* matches you have. It
seemed to be a natural application for hashes (associative
arrays). So, during a subway ride, I was able to put together such a
program.

First, the word list. I'm running Linux, so I have
/usr/share/dict/words, which has a whole bunch of words, not all legal
for Scrabble, one per line. Then I found an old Scrabble word list on
the web, likewise one word per line, which is what I ended up using.

The observation that a hash was the thing led to the following
subroutine for turning a word into a hash:

sub makehash {

  my ($s)=@_;

  $s=uc($s); # my dictionary has words in uppercase, but user will
             # probably type lowercase

  my @s=split //, $s; # divide word into array of individual chars

  my %h=();

  for my $i (@s) {
    $h{$i}++;
  }

  # for example, $h{'A'} is the number of A's in the word

  return %h;

}

Now, I'm looking for bingos (to use up all the letters from my rack,
plus maybe one on the board), so I need any candidate word to have at
least as many of each letter as I do on my rack (plus any letters I'm
planning to use on the board). Conversely, if the dictionary word has
*fewer* of any letter than I have on my rack, I can reject it right
away.

I put in one more refinement: I might have a blank on my rack, so as
well as inputting to the program the letters I would like to use up
(my rack plus anything on the board), I also enter the length of word
I would like to find. That way, any dictionary words not that length
can be rejected without even making a hash for them.

With that in hand, the strategy is:

- read the desired letters and word length from the command line
- turn those letters into a hash
- for each word in word list:
  - reject if wrong length;
  - turn into a hash
  - if examination of the hash reveals that the dictionary word has
    fewer of any letters than the input does, that dictionary word
    can be rejected.
  - if dictionary word is not rejected, print it out
  
which leads to the following main program:

my $letters=shift;
my $length=shift;

$length+=2; # one is the line-ending newline, but I don't know what
            # the other is
%l=makehash($letters);


open IN, "TWL06.txt"; # or die....
WORD: while (<IN>) { # the dictionary word is in $_
  next unless length==$length;
  my %m=makehash($_);
  for my $l (keys %l) {
    next WORD if $l{$l}>$m{$l};
  }

  print;
}

As an example, I had INGESTI on my rack. I had seen that this makes
IGNITES, but there was no place to put it. There was, however, an open
N. Any help? Could I make an 8-letter bingo?

ken@ken-laptop:~/words$ perl search.pl ingestin 8
GINNIEST

Woo hoo!

Another example: suppose I have ROTANE plus a blank. What 7 letter
bingos do I have? Quite a few:

ken@ken-laptop:~/words$ perl search.pl rotane 7
ANOTHER
ATONERS
BARONET
ENACTOR
NEGATOR
OPERANT
OUTEARN
PRONATE
PROTEAN
REBOANT
SANTERO
SENATOR
TONEARM
TREASON

Tuesday, January 11, 2011

making symbolic links

I always forget this. I often want to make a short name for a directory with a long name. The syntax for that is

ln -s longdirectoryname shortname

where the long name is the one that exists and the short name is the one I want to create. Do it in the directory where you want the short name to be (like the home folder). 

At http://www.tech-recipes.com/rx/172/create_a_symbolic_link_in_unix_solaris_linux/ there is a handy mnemonic (if such it is): ln -s works just like "cp" or "mv".

Sunday, January 9, 2011

Art






The Shed, by Megan.

Saturday

On Saturday morning we awoke to this:


and this. There is a driveway under there somewhere.




So Megan


and Daddy went out to shovel and play in the snow. We had a couple of snow mountains (not snowmen as the snow was too fluffy), which Megan then sat on and otherwise destroyed, and some snow sandcastles, and



some complicated business involving large numbers of flowerpots.