Writing an algorithm to decide whether a target number can be reached with a set of other numbers and specific operators?

前端 未结 3 1990
有刺的猬
有刺的猬 2020-12-09 07:01

I\'m trying to learn more about algorithm design, and I\'ve set myself the challenge of creating a simple game that presents users with an array of numbers, a target number,

3条回答
  •  难免孤独
    2020-12-09 07:18

    1. Enumerate all possible expressions. For numbers 1,2,3,and operator + and - ,you can get:1+2+3,1+2-3,1-2+3,1-2-3.

    2. Evaluate all possible expressions.

提交回复
热议问题