Calculate the fastest solution Watch

jsmith6131
Badges: 16
Rep:
?
#1
Report Thread starter 1 month ago
#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
reply
winterscoming
Badges: 19
Rep:
?
#2
Report 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
reply
DFranklin
Badges: 18
Rep:
?
#3
Report 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
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Latest
My Feed

See more of what you like on
The Student Room

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

Personalise

University open days

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

How did your AQA A-level Business Paper 1 go?

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%

Watched Threads

View All