Minimum of steps is
9
I found 10 solutions:
Solution 1
1 + 1 = 2
1 + 2 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 + 19 = 361
361 * 342 = 123462
123462 - 6 = 123456
Solution 2
1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 * 19 = 6498
6498 * 19 = 123462
123462 - 6 = 123456
Solution 3
1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 18 = 6498
6498 * 19 = 123462
123462 - 6 = 123456
Solution 4
1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 - 19 = 342
342 * 361 = 123462
123462 - 6 = 123456
Solution 5
1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 19 = 6859
6859 * 18 = 123462
123462 - 6 = 123456
Solution 6
1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 + 19 = 361
361 * 342 = 123462
123462 - 6 = 123456
Solution 7
1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 * 19 = 6498
6498 * 19 = 123462
123462 - 6 = 123456
Solution 8
1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 18 = 6498
6498 * 19 = 123462
123462 - 6 = 123456
Solution 9
1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 - 19 = 342
342 * 361 = 123462
123462 - 6 = 123456
Solution 10
1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 19 = 6859
6859 * 18 = 123462
123462 - 6 = 123456
Program which I made in C#:
using System;
using System.Collections.Generic;
using System.Linq;
namespace LowestPossible
{
class Program
{
const int NUMBER_TO_FIND = 123456;
const int MAX_DEPTH = 10;
public static void Main()
{
var list = new List<Tuple<int, string>>();
list.Add(new Tuple<int, string>(1, ""));
rec(list, 1);
}
public static void rec(List<Tuple<int, string>> row, int step)
{
var lastRes = row.LastOrDefault();
if (lastRes.Item1 == NUMBER_TO_FIND)
{
Console.WriteLine(String.Join("", row.Select(a => a.Item2 + " = " + a.Item1.ToString())) + " <" + (step-1) + ">");
return;
}
if (step == MAX_DEPTH || lastRes.Item1 < 1)
{
return;
}
foreach (var num in row)
{
var newRow = new List<Tuple<int, string>>(row);
newRow.Add(new Tuple<int, string>(lastRes.Item1 + num.Item1, " + " + num.Item1));
rec(newRow, step + 1);
newRow.RemoveAt(step);
newRow.Add(new Tuple<int, string>(lastRes.Item1 - num.Item1, " - " + num.Item1));
rec(newRow, step + 1);
newRow.RemoveAt(step);
newRow.Add(new Tuple<int, string>(lastRes.Item1 * num.Item1, " * " + num.Item1));
rec(newRow, step + 1);
newRow.RemoveAt(step);
}
}
}
}
The output does not have nice format but it was made only for me. Also code is optimized to run in dotnetfiddle, but originaly it was for 2020 question. It runs too long for this question so it doesn't work for this one in dotnetfiddle due to timeout.