Word ladder: Difference between revisions

Content deleted Content added
Wherrera (talk | contribs)
m →‎{{header|Julia}}: save a step
Wherrera (talk | contribs)
→‎{{header|Julia}}: variable names
Line 40: Line 40:
<lang julia>const dict = Dict(word => length(word) for word in split(read("unixdict.txt", String), r"\s+"))
<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)
function targeted_mutations(str::AbstractString, target::AbstractString)
working, tried = [[s]], Set{String}()
working, tried = [[str]], Set{String}()
while all(a -> a[end] != target, working)
while all(a -> a[end] != target, working)
newworking = Vector{Vector{String}}()
newworking = Vector{Vector{String}}()