# Calculate the fastest solutionWatch

Announcements
#1
For a list of values (n), calculate value (x) using ONLY the values in list (n) and the symbols (+, -)

e.g: n = 1,2,3,4,5
x = 6

Fastest solution = 5+1 or 4+2 or 3+3

Is there a programme online that can work this out?
Or, is there a method I can use in Python to work this out?

Thanks
0
4 weeks ago
#2
You can certainly do it in Python - the algorithm is very similar to this: https://stackoverflow.com/questions/...ch-a-given-sum
1
4 weeks ago
#3
(Original post by winterscoming)
You can certainly do it in Python - the algorithm is very similar to this: https://stackoverflow.com/questions/...ch-a-given-sum
If you can repeat values as the OP indicates, a dynamic programming approach will be better I think.
1
X

new posts
Latest
My Feed

### Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

### See more of what you like onThe Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

### University open days

• SOAS University of London
Wed, 29 May '19
• University of Exeter
Thu, 30 May '19
• Cranfield University
Cranfield Forensic MSc Programme Open Day Postgraduate
Fri, 31 May '19

### Poll

Join the discussion

Loved the paper - Feeling positive (179)
22.86%
The paper was reasonable (366)
46.74%
Not feeling great about that exam... (145)
18.52%
It was TERRIBLE (93)
11.88%