Is there a better way to generate all equal arithmetic sequences using numbers from 1 to 10?

Problem:

The numbers are from 1 to 10 . Place an equal sign (somewhere between them) and any arithmetic operator {+ - * /} , so that an ideal integer results in equality (both the final result and the partial results must be an integer)

Example:

1 * 2 * 3 * 4 * 5/6 + 7 = 8 + 9 + 10

1 * 2 * 3 * 4 * 5/6 + 7-8 = 9 + 10

My first idea to solve this problem was to use backtracking:

  • Generate all the possibilities of placing operators between numbers
  • For one such possibility, replace all operators one by one with an equal sign and check if we have two equal results

.

, : , , -, - ?

+4
1

. . , , dict. .

226 Python 0,15 . , , , ? 20683 . : 10327 10356 .

, , . , allov , . , - , , . 2, 3, 5 7 - , . 4 . , 2*3*4*5/6, 4*5*6*7/8 3*4*5*6*7*8/9. , , , , - .

+4

All Articles