Enumerating Contract Bridge Auctions with Lisp

I’ve been a fan of Contract Bridge for a long time.  I’m really bad at it, but all the same, I find it fascinating and compelling.  One of the interesting facts about Bridge is the astronomical number of possible auctions.  For any given deal, there are over 128 × 1045 possible auctions. The exact number is:

128,745,650,347,030,683,120,231,926,111,609,371,363,122,697,557

That’s a lot!  Being the nerd that I am, I decided to dust off my LISP skills (mostly neglected since college) and write a program to enumerate them.  To wit:

(setf allbids
      '("1C" "1D" "1H" "1S" "1NT"
        "2C" "2D" "2H" "2S" "2NT"
        "3C" "3D" "3H" "3S" "3NT"
        "4C" "4D" "4H" "4S" "4NT"
        "5C" "5D" "5H" "5S" "5NT"
        "6C" "6D" "6H" "6S" "6NT"
        "7C" "7D" "7H" "7S" "7NT"))

(defun printMore (bidList bidStr)
  (if (null bidList) nil
    (progn
      (mapcar #'(lambda (p)
                  (printAuctions bidList (concatenate 'string bidStr p (car bidList))))
              '(" " " P " " P P "))
      (printMore (cdr bidList) bidStr))))

(defun printAuctions (bidList bidStr)
  (let* ((matrix
          '(nil
            " P P Dbl"
            " P P Dbl Rdbl"
            " P P Dbl P P Rdbl"
            " Dbl"
            " Dbl Rdbl"
            " Dbl P P Rdbl"))
         (bidMatrix (mapcar #'(lambda (x)
                                (concatenate 'string bidStr x)) matrix)))
    (dolist (x bidMatrix)
      (progn
        (print (concatenate 'string x " P P P")
               (printMore (cdr bidList) x))))))

(defun printSomeAuctions (startBid &optional (prefix nil))
  (let ((bidPos (position startBid allbids :test #'equal)))
    (if bidPos
        (let ((bidList (nthcdr bidPos allbids)))
          (printAuctions bidList (concatenate 'string prefix (car bidList)))))))

(defun printAllAuctions ()
  (progn
    (print "P P P P")
    (mapcar #'(lambda (p)
                (printSomeAuctions "1C" p))
            '(nil "P " "P P " "P P P "))))

(printAllAuctions) will iterate through and print out every possible Bridge auction.  Don’t hold your breath waiting for it to finish, though.  The computer I was using, a Linux box running CLISP, printed out around 14,000 auctions per second.  At that rate, it will take 291.4 × 1033 years to complete.  That’s over 21 septillion (21 × 1024) times the age of the known universe.

ZyXEL WAP3205 – Not Recommended

Last Fall, I got it into my head that I needed to upgrade my home network’s wireless access point (WAP).  I’d been using an old, but trustworthy, Netgear WG602V2 since around 2001-2002, and while it worked, I was hoping to get something with a bit more range, that supported 802.11N and various newer features.  I decided to try out the ZyXEL WAP3205.

The ZyXEL started out OK, although it did not seem like much of an upgrade over the Netgear.  The range and data throughput weren’t noticeably better.  The problems started after a few months, when I upgraded my Macbook Pro to Mountain Lion.  When I woke my laptop from sleep mode, the wi-fi would no longer automatically re-connect.  I had to manually re-join the network every time.  A pain, but not a show stopper.

The next problem started when I began playing around with AirPlay/AirPrint, both of which use Apple’s Bonjour service, which uses multicasting.  With the ZyXEL, Bonjour was flaky at best: sometimes it worked, sometimes it didn’t.  I couldn’t figure out any rhyme or reason to it, other than that the WAP was definitely the culprit, as Bonjour services worked fine over wired connections.

I read on a web site somewhere that the latest firmware on the WAP3205 addressed some issues with Bonjour.  I was skeptical, because the firmware release notes didn’t mention anything about Bonjour, but I went ahead and updated anyway.  This turned out to be a disaster.  Not only did the new firmware not fix the Bonjour issues, it also messed up the networking on the WAP somehow.  After upgrading, the wired ethernet interface on the WAP started randomly freezing up.  The wireless was still active, but the WAP stopped responding to pings.  This happened a couple of times.  Another time, the interface stayed up for several hours, then froze up my entire LAN.  None of my wired devices could connect to anything else on the LAN.  When I unplugged the WAP3205, LAN connectivity instantly came back.  Word of warning to WAP3025 owners: don’t install firmware version 1.00(BFR.7)C0 (released November 2012).  This is the version that caused the instability with the LAN interface.  I’d recommend waiting until a newer firmware revision is released before updating.  Caveat Emptor.

After the LAN freeze-up, I ditched the WAP3205 and went back to my old Netgear.  With the Netgear, Bonjour works great, I’m able to use AirPlay/AirPrint without any issues, and when my laptop wakes from sleep, the wi-fi reconnects without any problems.  The Netgear isn’t perfect, though.  I’m not able to get AirPlay mirroring working.  The mirroring starts up and works for a few seconds, but then it shuts itself off.  I had the same issue with the ZyXEL, so I’m not sure if the WAP is to blame for this or not.  Searching the net hasn’t turned up a good explanation for this behavior so far, but I’m going to keep looking for a fix.

In short: If you need a reliable wi-fi access point that works with Bonjour, stay away from the ZyXEL WAP3205!

Riding in 2013 – Another warm winter so far

So it’s 2013, and I’m still riding.  A lot has changed with my riding routine this year.  For starters, I’m no longer recording ride stats in a spreadsheet.  I am using RunKeeper instead, and it’s been a great time saver.  I still plan to keep track of mileage for each of my bikes separately, though, so I’ll know when to replace tires, chains, etc.

I am also commuting to a new office, on the 6th floor of the Administration building at UMBC.  This requires me to ride the elevator to get in and out of the building, a prospect I was initially dreading.  However, so far it hasn’t been too bad.  The wait for the elevator isn’t bad, because it tends to be going the same direction I’m going, that is, up in the mornings and down in the evenings.  Although the elevators are sometimes crowded, I can wait for the next one and it’ll usually be empty.  The elevators aren’t huge, but the bike fits inside just fine.  Granted, it’s winter session and the campus isn’t crowded to begin with.  My tune may change in a couple of weeks when the spring semester starts.  We’ll see.

And finally, I’m trying out an Osprey Momentum 34 backpack, in lieu of panniers.  I really like the pack so far, and will write more on it after I’ve been using it for a month or so.

This winter has started off warm, similar to last winter.  I’ve been riding my road bike almost exclusively.  The past few days have been wet and drizzly.  A couple days ago, my rear fender started making this insidious rubbing noise.  It sounded like a leaf was caught between the fender and the tire, but I couldn’t find one.  It kept getting worse and worse, until finally I took the wheel off to get to the bottom of it.  It turns out that the silver mylar lining on the inside of the fender (Planet Bike Cascadia) was starting to peel away from the fender, and the loose end was rubbing against the tire.  I pulled on it, and about half of it peeled off the fender.  Now I have a fender that’s half silver and half clear, but no more rubbing noise.  I wonder how long before the remaining mylar starts to peel away.  The mylar seems to be totally cosmetic, and the fender is 5 years old and still fully functional, so no complaints.

Instant Hot Water Tank Repair

One of the must-have appliances in our kitchen is an instant hot-water tap. Once you’ve gotten used to instant cups of hot tea, you’ll never want to be without one. Unfortunately, while these gadgets are a great luxury, they have a reputation for being unreliable. The most popular brand, In-sink-erator, is well known for lasting 2 or 3 years before the tank starts leaking. Indeed, that’s what happened to ours, while it was still under warranty. We contacted In-sink-erator, and they helpfully shipped us a brand new tank at no cost. The only problem was that the new tank also leaked. The ultimate solution was to replace the In-sink-erator with a different brand, a Waste King. The Waste King seems like a better made unit, and it’s been working fine for a month or so now, but the jury is still out as to its longevity.

With our family happily tapping instant hot chocolate again, I decided to take a closer look at the leaky In-sink-erator tanks. I wanted to pinpoint where they were leaking and see if I could repair them. It’s next to impossible to find leaks while the tank is in service, because it’s under the sink where it’s hard to get to, and the tank’s internal plumbing is hidden behind the case and the styrofoam tank insulation. The best way to find the leak is to take the tank and faucet out of service, remove the case and insulation, hook the faucet up to a temporary water supply, turn the water on, and look for the leak. The In-sink-erator faucet attaches to the water supply with ¼” copper tubing with compression fitting.  I went to my local Lowe’s and picked up a ¼” compression to ½” male NPT adapter, and a ½” female NPT to female garden hose adapter, and used these to hook the faucet and tank up to my laundry tub faucet. With the case and insulation off the tank, I was able to pinpoint the leaks in both my original and replacement tanks.

The In-sink-erator tanks have a well-known issue where the plastic tubing fails between the tank and the backflow reservoir.  It turned out that this wasn’t the problem with either of my tanks.  On both my tanks, the culprit was a plastic bulkhead fitting: the original tank leaked at the water supply fitting at the top, and the replacement leaked at the drain fitting on the bottom.  These fittings don’t appear to be serviceable, so the only option appears to be to replace them with higher quality bulkhead fittings.  In the meantime, I salvaged a useable tank by using the top half of the replacement with the bottom half of the original.  We’re happy with the Waste King dispenser for now, but if and when it fails, we now have a working In-sink-erator that we can fall back on.

2012 in review

I ended up 2012 with around 155-160 rides (I got lazy about recording my rides at the end of the year, so I don’t have an exact number).  I may stop keeping track of individual rides in 2013 because I’m not getting much out of it any more — I’ll continue to track mileage, mainly because it’s useful for knowing when to replace tires, chains and things like that, and I may “check off” days that I rode, just to have a count…  but anything beyond that seems superfluous.  OK, maybe I lied.  I recently installed “Runkeeper” on my iPhone, and I’m using it for tracking my runs.  It apparently also works for cycling, so I’ll probably give it a shot.  If it’s easy and seems useful, I’ll let it keep track of my ride stats for me.  Point being, I’m done manually recording detailed ride stats, other than total mileage.

I’m on the tail end of my 2-week holiday break, and I missed my last couple of rides to work due to illness, so I haven’t been on a bike for a while.  I just got my mountain bike ready for winter.  It’s now sporting studded tires, platform pedals with power grips, and my latest new gadget: Bar Mitts.  Bar Mitts are large neoprene sleeves that cover the entire end of the bars, including brake levers and shifters.  You stick your hands into them kind of like a giant oven mitt, and they’re supposed to create a wind barrier that keeps your hands warm.  The weather forecast for my first day back at work (Thursday 1/3) is looking cold, so I’ll likely get to test the Bar Mitts out soon.  Once I’ve ridden with them a couple of times, I’ll post a review.

That time of year again..

We’re now halfway through November, so I’m once again riding home at dusk.  I leave UMBC at 5:00 and get home around 5:45.  By Thanksgiving, the sunset will be pushing back towards 4:45.  At our latitude/longitude, the earliest sunset is about 4:44pm and usually falls around December 9-10.  So the next few weeks will be my darkest rides home of the year.  I’m riding with the same lighting setup as last year:  a Planet Bike Blaze 2w and 1w both mounted on my front bars; a Blaze ½w on my helmet; 3 red flashers (various brands) mounted on the back of the bike (1 on each pannier and one on my rack); and a flasher on the back of my helmet.  I’ve been really happy with this setup.  In particular, the helmet-mounted headlight is great.  It’s not enough to light up the road ahead by itself, but it lights up wherever I happen to turn my head.  It’s great for making turns, because I can turn my head to light up the section of road where I’m about to turn, before it’s illuminated by the main headlights.  It’s also good for lighting up objects to either side of the road, looking at my cyclometer, chain/drive train, etc.  I find it particularly useful in areas without a lot of ambient lighting.  The Planet Bike lights have a very user-friendly mounting bracket, which makes them very nice for commuting.  It’s easy to move them back and forth between bikes, take them off when locking up the bike, etc., and if necessary, I can use one as a flashlight.  The lights also use standard AA batteries.  I use NiMH rechargeable batteries, which work great.  I steer clear of lights that use proprietary battery packs, because they tend to be expensive to replace.

In other news, I bought a new jacket this year too.  It’s a Novara Conversion Jacket (REI house brand) with removable sleeves.  I’ve always been a fan of removable sleeves, particularly in Spring and Autumn.  I had a similar jacket that I bought from Performance, but one of the sleeve zippers broke after about a year.  The REI jacket was about $15 more than the Performance version, but it’s better made in almost every way.  The zippers are higher quality, and it also has front pockets and a hanging loop on the collar, all of which the Performance jacket lacked, and the material seems higher quality.  I’ll be sure to post more about it after I’ve ridden with it for a while.

October Post

I needed to get a blog post in for October, to keep my streak alive: I have managed to write at least one blog entry each month since late 2009.

We just survived Hurricane Sandy, which was reportedly the largest storm ever to strike north of Cape Hatteras, and also it’s been quite some time since the Mid Atlantic was impacted by a hurricane this late in the year.  But then again, my memory only goes back to Hurricane Floyd in the late 1990s.  All in all, Sandy wasn’t too hard on our immediate area.  We got lots of rain and wind, but in general, it wasn’t as much of an impact as the Derecho that hit us last June, or the one-two punch of Hurricane Irene and Tropical Storm Lee in Summer 2011.  It was our second hundred-year storm in a row.  Statistically speaking, we should be good to go now until, oh, the year 2200 or so.

I took my bike through Patapsco State Park, and it was a big mess, as it always is after large rainfall events.  The river was running high and fast, and there were 8 or 9 downed trees on the Grist Mill Trail, as well as one huge mudslide.   The carnage was all on the lower section of the trail, between the swinging bridge and Lost Lake.  The upper Grist Mill, between the swinging bridge and Ilchester Rd, was clear, as was River Rd from the Avalon day use area out to the swinging bridge.

I then took River Rd from the park out to Frederick Rd.  The road had some mud and standing water in spots, but was otherwise in good shape.  The problem was that Thistle Rd was closed off (probably a fallen tree; I didn’t investigate) so there was a ton of car traffic diverted onto River Rd.  I took Frederick Rd down towards Ellicott City, and up Oella Ave., which was in good shape.  The No. 9 Trolley Trail was clear from Oella Ave. to its terminus at Chalfonte Dr. in Catonsville.  In Catonsville, Asylum La. was blocked off due to downed trees and power lines, so I had to detour onto Valley Rd. to get to UMBC.  I’m sure conditions will improve over the next several days.

In other news, my office is going to be moving.  I am staying at UMBC, but I’m moving from a building with nice, easy, ground-level access to my office, to a 6th-floor office which will require me to take an elevator.  This is going to require some changes to my bike commuting routine, so stay tuned for some new tips as I get settled in over the next several weeks.

Chain Joinery – Fixing stiff links

I’m still working on getting everything working smoothly with my old ’93 Specialized Rockhopper, after replacing the chain, cassette, front cranks and sprockets.  To compensate for larger chainrings, I ended up having to add a couple of links to my chain, and I thought I’d pass on a tip.

I have always found it frustrating trying to put chains back together with a chain tool.  I would always start by pushing the rivet all the way back into the link, and almost invariably, the link would end up so stiff I could barely move it.  I could never figure out how to get it loosened up properly.  My chain tool includes a secondary “ramp” for fixing stiff links, but it never seemed to do me any good.  It would spread the link apart a little bit, but the link would remain stiff.  Working the chain back and forth laterally, as recommended on various web sites, didn’t work for me either.  It was very frustrating, until I came up with the following strategy:

  1. Begin reassembling the chain with the chain tool as you normally would, except instead of pushing the rivet all the way into the link, tighten the chain tool only about 1 full turn or so, just so the rivet goes in far enough to hold the link together.
  2. Remove the chain from the tool, and verify that the link moves freely.
  3. Put the chain back in the tool (regular position, not “stiff link” position) and tighten another ¼ to ½ turn.
  4. Repeat steps 2 and 3, pushing the rivet in just a tiny bit each time, and testing the link, until you feel the link start to stiffen up.
  5. Put the chain into the “stiff link” position on the chain tool.  Usually, this is the position closest to the crank handle.  Tighten handle around ¼ turn, just enough to slightly spread the link.  Never turn the handle more than ¼ turn in this position, or you may distort the link.
  6. Remove tool from chain.  Check to make sure the link has loosened up.
  7. Continue to push the rivet into the link little by little, checking the link for tightness each time (steps 2-3), and loosening it up as needed (steps 5-6), until the rivet is all the way in the link.  That should do it!

I’ve had great success with this method.  The trick is to keep the link loose by making small, gradual adjustments, rather than trying to free the link up after the rivet has been inserted all the way.  Good luck and happy riding.

Drive Train

We’re now about midway through September.  The first week of September featured weather similar to the inside of a gym locker room.  This past week, the weather has been beautiful.  We’ll see what the rest of the month holds.

I haven’t ridden my mountain bike since I broke my chain a few weeks back.  I put a new chain on, but then I decided I should also replace the drive train.  The cassette and chainrings were all mid-1990s vintage, and probably completely worn out.  I wouldn’t be surprised if they contributed to the chain’s demise.  So anyhow, replacement 7-speed MTB cassettes are pretty cheap online.  I bought a new SRAM cassette for around $17.  We’ll see how it holds up.  The gearing is a bit different from my old one; the small cog has 12T vs 13T on the old cassette, which will give me a slightly higher gear going down hills.  The largest cog is also larger, giving me a lower gear for climbs.  I don’t really need a lower gear on this bike with the kind of riding I do, but as you can imagine, there isn’t a terribly wide selection of gearing choices in 7-speed cassettes nowadays.  This was about the best I could find given how I’m going to ride it.

Buying new chainrings was an interesting lesson in economics.  It’s very hard to find replacement chainrings for old cranksets, and when you do, the cost of 3 new ones often adds up to more than the price of a brand new crankset (which includes the chainrings).  There was nothing wrong with my existing crank, but I ended up replacing it, because it was cheaper than buying 3 new chainrings separately.  The new crank is a Shimano Acera M361, with the same specs and gearing as the old one, and a chain guard to boot — I am a big fan of chain guards now that I’ve had one on my road bike for awhile.  One thing to be aware of, is that some of the cheaper cranksets have the chainrings permanently riveted on.  If you have any intention of replacing chainrings as they wear out (which is more likely if you do a lot of riding), you’ll want to stay away from these.  Of course, if you’re like me and wait 18 years to swap chainrings, it won’t matter, because you’ll be replacing the cranks anyhow.  🙂

I’ve got the parts installed on the bike, but still need to readjust the derailleurs and get it shifting smoothly.  Once I do, I’ll report back on how the bike rides.  I’m hoping it’ll be an improvement.

Summer’s End

Labor Day weekend is looming, the kids are back in school, the traffic is back in the mornings, and multiple tropical systems are swirling around the Atlantic.  Must be the end of August.  This time last year, we had just survived Hurricane Irene, and were bracing for Tropical Storm Lee.  Hopefully, September 2012 will be less exciting.

The dog days of summer weren’t particularly kind to my riding this year, as they have been in years past; but I did manage to finish August up with 14 rides.  If the weather cooperates, September can be a pretty good riding month, so we’ll see how that works out.  I’ve got a couple of business trips coming up in October that will likely cut into my ride totals that month.  My original goal of 180 rides this year is looking less likely, but that’s OK.  I am trying to get a little less goal-oriented about my riding, particularly as I’m cutting back on it a bit (at least distance, if not frequency) to do some running and other cross-training.

With all the extra school traffic now, I’m once again steering clear of Montgomery Road in the mornings.  Today, I cut through CCBC Catonsville again, the same route I took on April 20 and one or two other times since then.  It’s still a good route, but boy is it hilly.  Actually, most of my rides that avoid Montgomery Rd seem to be hilly.  It’s just the price you pay to stay out of traffic, I guess.