Minimal steps down to 1: Difference between revisions

m
Line 187:
 
=={{header|Julia}}==
NonThis is a non-recursive solution that is memoized for the count-only portions of the task. When the steps are to be printed, the solution isbut not memoized in order to listwhen all possible paths of the shortest length (all solutions). Implementedare asto abe generic solution for any functions acting on an integer and taking any range of second arguments, with the goal solution also specifiablelisted. To do so generically, it is also necessary to specify a falure condition, which in the example is falling below 1.
 
Implemented as a generic solution for any functions acting on an integer and taking any range of second arguments, with the goal solution also specifiable. To do so generically, it is also necessary to specify a failure condition, which in the example is falling below 1.
<lang julia>import Base.print
 
Line 200 ⟶ 202:
end
 
function Base.print(io::IO, ao::ActionOutcome) = print(io, "$(ao.act.f) $(ao.act.i) yields $(ao.out)")
print(io, "$(ao.act.f) $(ao.act.i) yields $(ao.out)")
end
 
memoized = Dict{Int, Int}()
4,105

edits