Word ladder: Difference between revisions

Content deleted Content added
Wherrera (talk | contribs)
m →‎{{header|Julia}}: allow multiple solutions
Wherrera (talk | contribs)
m →‎{{header|Julia}}: save a step
Line 46: Line 46:
for arr in working
for arr in working
s = arr[end]
s = arr[end]
push!(tried, s)
for j in 1:length(s), c in 'a':'z'
for j in 1:length(s), c in 'a':'z'
w = s[1:j-1] * c * s[j+1:end]
w = s[1:j-1] * c * s[j+1:end]
Line 54: Line 55:
end
end
isempty(newworking) && return [["This cannot be done."]]
isempty(newworking) && return [["This cannot be done."]]
for arr in newworking
push!(tried, arr[end])
end
working = newworking
working = newworking
end
end