Mathematica处理24点问题初步
程序员文章站
2022-03-02 10:42:30
...
a = Tuples[{"+", "-", "*", "/"}, 4];
b = Permutations[{5, 6, 7, 10, 3}];
Drop[Table[
If[((v = (ToString[#] & /@ ({[email protected]
n[[1]], ({m, n[[2 ;; 5]]} // Transpose)} // Flatten)) // StringJoin) //
ToExpression) == 24, v, 0], {m, a}, {n, b}] // Flatten // Union, 1]
推荐阅读