How to represent a number with given numbers using arithmetic operations?

This is a question. “Given an array of numbers and another number, find out if you can manipulate an array of numbers using standard mathematical methods to equal the number of other numbers, for example, given 5 and 10, can you make 50 × 5 * 10 = 50, so yes” . (Let only arithmetic operations be allowed for simplicity).

I would suggest using brute force search (with some branch and border). Does it make sense?

+3
source share
6 answers

Haskell Programming, Chapter 11: The Countdown Problem

+1
source

. - ... , , .

, , . , . , , A *.

: .

+4

  • Numbers?
  • ?
  • standard mathematical techniques?
    • ?
    • , ?
    • ?
    • ?

..

+1

, .

. a * b = b * a.

0

. , .

S - , . |S - Value(E[i])|, Value(E[i]) - i - .

, .

, , , .

, , , , , .

(- S, ), , . , , , , , , , .

0

: - ? , x -x, 1/x, x! sqrt (x) ""?

, , . , .

, : BNF .

< a > :: = 5 | 10

, , , 20 . . " " , .

0

Source: https://habr.com/ru/post/1773927/


All Articles