Subject: Re: [xsl] Word Ladders as an example of a "Find shortest path between two nodes in a graph" problem From: "Sean B. Durkin" <sean@xxxxxxxxxxxxxxxxx> Date: Tue, 27 Nov 2012 22:47:11 +1100 |
_Alternative 1:__ _ fn:fold-left( 0, function($distance, $code-diff) { if ($code-diff) then $distance + 1 else $distance }, let $c1 := string-to-codepoints($pStr1), $c2 := string-to-codepoints($pStr1) return for $i in 1 .. min(count($c1),count($c2)) return $c1[$i] - $c2[$i] )
_count( let $c1 := string-to-codepoints($pStr1), $c2 := string-to-codepoints($pStr1) return for $i in 1 .. min(count($c1),count($c2)) return 1[$c1[$i] eq $c2[$i]] )
Faithfully, Sean B. Durkin
Dear XSLT professionals,
In case you are interested in solving the Word Ladders problem first formulated by Lewis Carroll, or just in an XSLT solution of the "Find shortest path in graph" problem, you might be interested to have a look at the implementation in my latest blog post:
http://dnovatchev.wordpress.com/2012/11/26/word-ladders-or-how-to-go-from-angry-to-happy-in-20-steps/
Any feedback about this implementation and suggestions for further optimization are welcome.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Word Ladders as an exampl, Chris Maloney | Thread | Re: [xsl] Word Ladders as an exampl, Dimitre Novatchev |
Re: [xsl] efficient traversal of co, Graydon | Date | Re: [xsl] Word Ladders as an exampl, Dimitre Novatchev |
Month |