Word ladder: Difference between revisions
Promote to full task
m (added related tasks.) |
(Promote to full task) |
||
Line 1:
{{
Yet another shortest path problem. Given two words of equal length the task is to transpose the first into the second.
Line 140:
<lang fsharp>
// Word ladder: Nigel Galloway. June 5th., 2021
let fG n g=n|>List.partition(fun n->2>Seq.fold2(fun z n g->z+if n=g then 0 else 1) 0 n g)
let wL n g=let dict=seq{use n=System.IO.File.OpenText("unixdict.txt") in while not n.EndOfStream do yield n.ReadLine()}|>Seq.filter(Seq.length>>(=)(Seq.length n))|>List.ofSeq|>List.except [n]
let (|Done|_|) n=n|>List.tryFind((=)g)
|