Чет интересно даже стало))
Вот мое решение:
func gen() [][]int {
res := [][]int{}
for f := 0; f < 10; f++ {
for c := 0; c < 10; c++ {
if c == f { continue }
for j := 1; j < 10; j++ {
if j == f || j == c { continue }
x := int(f * c / j)
g := int(x / 10)
a := x % 10
if f != g && f != a && c != g && c != a && j != g && j != a && g != a && 100 > f * c/j && f * c/j > 9 && f * c%j == 0 {
res = append(res, []int{f, c, j, g, a})
}
}
}
}
return res
}
func calc() {
items := gen()
top:
for d := 0; d < 10; d++ {
for e := 0; e < 10; e++ {
if e == d { continue }
for b := 0; b < 10; b++ {
if d == b || e == b { continue }
for h := 0; h < 10; h++ {
if d == h || e == h || b == h { continue }
for _, item := range items {
if d*100+item[3]*10+item[2]+ item[2]*100+item[4]*10+e+ b*100+h*10+item[0]==d*1000+d*100+item[4]*10+b {
if item[0] != b && item[0] != d && item[0] != e && item[0] != h &&
item[1] != b && item[1] != d && item[1] != e && item[1] != h &&
item[2] != b && item[2] != d && item[2] != e && item[2] != h &&
item[3] != b && item[3] != d && item[3] != e && item[3] != h &&
item[4] != b && item[4] != d && item[4] != e && item[4] != h {
fmt.Println("a =", item[4], " b =", b, " c =", item[1], " d =", d, " e =", e, " f =", item[0], " g =", item[3], " h =", h, " j =", item[2])
break top
}
}
}
}
}
}
}
}
st := time.Now().UnixNano()
calc()
fmt.Println("Время выполнения (ms): ", (float64(time.Now().UnixNano()) - float64(st)) / 1e6)
# a = 4 b = 6 c = 9 d = 1 e = 5 f = 8 g = 2 h = 7 j = 3
# Время выполнения (ms): 0.498432