Word ladder: Difference between revisions

m
→‎{{header|Julia}}: allow multiple solutions
(julia example)
m (→‎{{header|Julia}}: allow multiple solutions)
Line 38:
 
=={{header|Julia}}==
<lang julia>const dict = Dict(word => length(word) for word in split(read("unixdict.txt", String), r"\s+"))
 
function targeted_mutations(s::AbstractString, target::AbstractString)
Line 51:
push!(newworking, [arr; w])
end
push!(tried, w)
end
end
isempty(newworking) && return [["This cannot be done."]]
for arr in newworking
push!(tried, warr[end])
end
working = newworking
end
Line 66 ⟶ 68:
</lang>{{out}}
<pre>
boy to man: [["boy", "bay", "may", "man"], ["boy", "bay", "ban", "man"], ["boy", "bon", "ban", "man"]]
girl to lady: [["girl", "gill", "gall", "gale", "gaze", "laze", "lazy", "lady"]]
john to jane: [["john", "cohn", "conn", "cone", "cane", "jane"]]
4,111

edits