wu :: forums
« wu :: forums - String Question »

Welcome, Guest. Please Login or Register.
Mar 30th, 2025, 11:47am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Icarus, william wu, towr, Eigenray, Grimbal, SMQ, ThudnBlunder)
   String Question
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: String Question  (Read 1064 times)
tuxilogy
Newbie
*





   


Posts: 45
String Question  
« on: Jul 1st, 2008, 8:28am »
Quote Quote Modify Modify

Given a string A, and a string B, and a dictionary, how would you convert A to B in the minimum no of operations, given that:
 
i) All the intermediate words must be from the dictionary
 
ii) An ‘operation’ is defined as:
 
a) Delete any character from a string ex dog → do
 
b) Insert any character into a string ex cat → cart
 
c) Replace any character in the string with another ex cat → cot
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: String Question  
« Reply #1 on: Jul 1st, 2008, 8:33am »
Quote Quote Modify Modify

Use a maze solver on the implicit graph formed by the constraints of the problem (vertices are words in the dictionary, edges are valid operations that turn one word into another).
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: String Question  
« Reply #2 on: Jul 1st, 2008, 8:34am »
Quote Quote Modify Modify

It boils down to finding the shortest path in a graph.
IP Logged
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: String Question  
« Reply #3 on: Jul 1st, 2008, 8:35am »
Quote Quote Modify Modify

Well, as towr suggests...  Sad
IP Logged
oriole
Newbie
*





   


Posts: 32
Re: String Question  
« Reply #4 on: Jul 1st, 2008, 10:14am »
Quote Quote Modify Modify

may be this can help  
 
http://en.wikipedia.org/wiki/Levenshtein_distance
 
Though it needs to be refined for condition (i).
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board