Minimal steps down to 1: Difference between revisions

Content added Content deleted
Line 239: Line 239:
end
end
if verbose
if verbose
println("There are ", length(solutions), " solutions for path of length ",
print("There are ", length(solutions), " solutions for path of length ",
numsteps, " from $start to $goal.\nExample: ")
numsteps, " from $start to $goal.\nExample: ")
for step in solutions[1]
for step in solutions[1]
Line 286: Line 286:


There are 2 solutions for path of length 1 from 2 to 1.
There are 2 solutions for path of length 1 from 2 to 1.
Example:
Example: divide 2 yields 1
divide 2 yields 1


There are 1 solutions for path of length 1 from 3 to 1.
There are 1 solutions for path of length 1 from 3 to 1.
Example:
Example: divide 3 yields 1
divide 3 yields 1


There are 3 solutions for path of length 2 from 4 to 1.
There are 3 solutions for path of length 2 from 4 to 1.
Example: divide 2 yields 2, divide 2 yields 1
Example:
divide 2 yields 2, divide 2 yields 1


There are 3 solutions for path of length 3 from 5 to 1.
There are 3 solutions for path of length 3 from 5 to 1.
Example: subtract 1 yields 4, divide 2 yields 2, divide 2 yields 1
Example:
subtract 1 yields 4, divide 2 yields 2, divide 2 yields 1


There are 3 solutions for path of length 2 from 6 to 1.
There are 3 solutions for path of length 2 from 6 to 1.
Example: divide 2 yields 3, divide 3 yields 1
Example:
divide 2 yields 3, divide 3 yields 1


There are 3 solutions for path of length 3 from 7 to 1.
There are 3 solutions for path of length 3 from 7 to 1.
Example: subtract 1 yields 6, divide 2 yields 3, divide 3 yields 1
Example:
subtract 1 yields 6, divide 2 yields 3, divide 3 yields 1


There are 3 solutions for path of length 3 from 8 to 1.
There are 3 solutions for path of length 3 from 8 to 1.
Example: divide 2 yields 4, divide 2 yields 2, divide 2 yields 1
Example:
divide 2 yields 4, divide 2 yields 2, divide 2 yields 1


There are 1 solutions for path of length 2 from 9 to 1.
There are 1 solutions for path of length 2 from 9 to 1.
Example: divide 3 yields 3, divide 3 yields 1
Example:
divide 3 yields 3, divide 3 yields 1


There are 1 solutions for path of length 3 from 10 to 1.
There are 1 solutions for path of length 3 from 10 to 1.
Example: subtract 1 yields 9, divide 3 yields 3, divide 3 yields 1
Example:
subtract 1 yields 9, divide 3 yields 3, divide 3 yields 1


There are 16 with 14 steps for start between 1 and 2000: [863, 1079, 1295, 1439, 1511, 1583, 1607, 1619, 1691, 1727, 1823, 1871, 1895, 1907, 1919, 1943]
There are 16 with 14 steps for start between 1 and 2000: [863, 1079, 1295, 1439, 1511, 1583, 1607, 1619, 1691, 1727, 1823, 1871, 1895, 1907, 1919, 1943]
Line 329: Line 320:


There are 1 solutions for path of length 1 from 2 to 1.
There are 1 solutions for path of length 1 from 2 to 1.
Example:
Example: divide 2 yields 1
divide 2 yields 1


There are 2 solutions for path of length 1 from 3 to 1.
There are 2 solutions for path of length 1 from 3 to 1.
Example:
Example: divide 3 yields 1
divide 3 yields 1


There are 2 solutions for path of length 2 from 4 to 1.
There are 2 solutions for path of length 2 from 4 to 1.
Example: divide 2 yields 2, divide 2 yields 1
Example:
divide 2 yields 2, divide 2 yields 1


There are 2 solutions for path of length 2 from 5 to 1.
There are 2 solutions for path of length 2 from 5 to 1.
Example: subtract 2 yields 3, divide 3 yields 1
Example:
subtract 2 yields 3, divide 3 yields 1


There are 3 solutions for path of length 2 from 6 to 1.
There are 3 solutions for path of length 2 from 6 to 1.
Example: divide 2 yields 3, divide 3 yields 1
Example:
divide 2 yields 3, divide 3 yields 1


There are 2 solutions for path of length 3 from 7 to 1.
There are 2 solutions for path of length 3 from 7 to 1.
Example: subtract 2 yields 5, subtract 2 yields 3, divide 3 yields 1
Example:
subtract 2 yields 5, subtract 2 yields 3, divide 3 yields 1


There are 5 solutions for path of length 3 from 8 to 1.
There are 5 solutions for path of length 3 from 8 to 1.
Example: divide 2 yields 4, divide 2 yields 2, divide 2 yields 1
Example:
divide 2 yields 4, divide 2 yields 2, divide 2 yields 1


There are 2 solutions for path of length 2 from 9 to 1.
There are 2 solutions for path of length 2 from 9 to 1.
Example: divide 3 yields 3, divide 3 yields 1
Example:
divide 3 yields 3, divide 3 yields 1


There are 2 solutions for path of length 3 from 10 to 1.
There are 2 solutions for path of length 3 from 10 to 1.
Example: divide 2 yields 5, subtract 2 yields 3, divide 3 yields 1
Example:
divide 2 yields 5, subtract 2 yields 3, divide 3 yields 1


There are 1 with 17 steps for start between 1 and 2000: [1699]
There are 1 with 17 steps for start between 1 and 2000: [1699]