Archive for March 10th, 2009


Algorithm note

I saw a post on one of my coding boards talking about a solution for an ‘interview-style’ problem.

The issue was to find the longest common substring.

What this means is: Given the word “abracadabra” you are looking for the longest repeated set of characters.

The longest repeated sub-string is “abra” which appears at positions 0 and 7 (counting from 0).

The solution the person presented involved putting the strings from smallest to largest into a dictionary (hash table) with counts of iterations.
a-4
b-2
ab-2

And then walking the tree to find the largest result. This solution seems odd to me.

My solution is to make a dynamic array that can be queried for contents. Further, doing it from longest to shortest:

Edit gwenix points out a string can’t be repeated until it’s no more than half the length. So start from longest string (len /2) rounded down.
End Edit

Solution:
Get longest string: abracadabra
Is string in array? YES? got answer and bail; No –> add to array
*Reduce look string by 1 character
Move to start of target string:
**Get look string: abracadabr
Is string in array? YES? got answer and bail; No –> add to array
Is look string at end of target string? Yes –> loop back to *; No –> move forward one character and loop back to **

This is massively not optimised for time or processing. But it’s a first stab.
Also, just pseudo code… loop counters would be my next pass.

Comments? Improvements?

I realise that not only isn’t everyone on FaceBook or Twitter; that some actively avoid it. I get it. I don’t go near MySpace for example.

That being said; I am utilising FaceBook and Twitter extensively this month for the process of moving.

Item 1: Truck loading day

Last evening I posted my call for Truck loading help.

I will be loading the truck the weekend of the 27th-29th. And I can use ALL hands on deck. I will be feeding and libating all that come by. Granted; if I know in advance… it helps me with getting the food in advance.

If you are on Facebook, head on over to the event page at http://www.facebook.com/event.php?eid=136178490243 and sign up. Even if you can only come for a short while; any time is beyond appreciated. If you’re not sure.. tick the "maybe" on the RSVP.

If you don’t like Facebook; drop a comment here.

Item 2: Take it away

THIS WEEEKEND: March 14th and 15th… We are having a massive packing and garage-ish sale, open house. Craft supplies, Books, Tables, TVs, Sofa, Bikes, Knick-Knacks, Chotchkies… And the cost to you is dragging it off. Donations accepted.

Come by, help box, get fed, or just rummage. We have a Lava Lamp ready for a new home!

Come one come all 🙂

Daily Twittering

  • 12:52 Suspect is upgrading to Jott’s new pay service only to have their entire service and website go down 2 minutes after you signed up. Timing!! #
  • 13:19 @T_Tommy I really hope Jott hasn’t just gone out of business; I just updated to the pay service. #
  • 13:20 @fraserspeirs How much storage is sitting there in the picture? I saw one labeled 1T, so you’ve gotta easily have a bunch there. #
  • 13:54 And now I must run an errand to Redmond. Despite road warnings. :-/ #
  • 14:17 Okay. To hell with errands. Daycare has early closure. Getting the boy. Will probably take an hour to go 11 miles and another hr. back. #
  • 14:36 Scary, scary weather so much for Aaron, going to day care.
    tinyurl.com/bdlk89 #
  • 15:04 Just arrived at daycare. Hiways are clear #
  • 15:18 And now the attempt to get home. #
  • 17:08 “Been caught stealing” came on the radio. Aiden in the back responded, “Puppy!” #
  • 17:10 Aiden found a file box Courtney is packing. When we told him it was hers, he put the cover on, picked it up, and took it to her room. #
  • 18:06 @jephjacques There’s a relatively easy way to do it on the mac if you have unix shell experience or bbedit. I could probably do it for you. #
  • 20:01 Voracious boy! Half a chicken sub and a half bagel AND a bowl of chicken noodle soup AND two cheese whips. Growth spurt, anyone??!?! Whoa!  #
  • 20:05 Happy mail day. Lots of info on my work town, the flight harness for Aiden, AND Flatland the animated film. Which is awesome! Heroes, 1 hr!! #
  • 20:12 @moon_ferret amen and thank you! The ladies of the house have been pouring over the information. There’s sushi in Chesterfield! Woot! Yay!! #

Automatically shipped by LoudTwitter