Skip to main content
Question Protected by gnat
Bumped by Community user
Bumped by Community user

Chatting with a friend about a game we used to play, and thinking how to implement it in code.

Here isare the rules: Given

Given a list of number e.g. {1,2,3,4} 
tryTry to use all the numbernumbers from the list to perform +,-,*,/ operationoperations to reach a target number e(e.g. 2).
The numbers can be used only once, the operators can be used more than once.

So one solution willwould be (1+3)*2/4 = 2

any ideaAny ideas for an algorithm to get at the answer(s)?

Chatting with a friend about a game we used to play, and thinking how to implement it in code.

Here is the rules: Given a list of number e.g. {1,2,3,4} try to use all the number from the list to perform +,-,*,/ operation to reach a target number e.g. 2

So one solution will be (1+3)*2/4 = 2

any idea?

Chatting with a friend about a game we used to play, and thinking how to implement it in code.

Here are the rules:

Given a list of number e.g. {1,2,3,4} 
Try to use all the numbers from the list to perform +,-,*,/ operations to reach a target number (e.g. 2).
The numbers can be used only once, the operators can be used more than once.

So one solution would be (1+3)*2/4 = 2

Any ideas for an algorithm to get at the answer(s)?

Source Link
jojo
  • 109
  • 2

Given an array of number, how to calculate to a target value

Chatting with a friend about a game we used to play, and thinking how to implement it in code.

Here is the rules: Given a list of number e.g. {1,2,3,4} try to use all the number from the list to perform +,-,*,/ operation to reach a target number e.g. 2

So one solution will be (1+3)*2/4 = 2

any idea?