Need a few tips on this program. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Need a few tips on this program.

https://code.sololearn.com/cmxB4ziUIizh/?ref=app Just finished writing this code. But I'm really struggling with how to print the BONUS point mentioned within the code itself i.e. if 225 is the output of the above code then how should I make it print like 225 is the minimal number with arrangement [40,1,10,5,25]. Will appreciate help! Thanks

3rd Aug 2019, 12:26 PM
Rohit Panchal
Rohit Panchal - avatar
4 Answers
+ 5
One method would be to create an extra list which saves every permutation of the given numbers, which corresponds to the values in list_sum. After obtaining min(list_sum), you can find the index of min(list_sum) within list_sum, and use this index to access the corresponding element in your list which stores the permutations. There is actually a more efficient way of obtaining the minimum sum and the combination without storing all of them into lists, but you're probably already aware of that. https://code.sololearn.com/cYF51JEG7H4y/?ref=app
3rd Aug 2019, 12:51 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
Hatsy Rei Thanks!
3rd Aug 2019, 1:02 PM
Rohit Panchal
Rohit Panchal - avatar
+ 1
~ swim ~ I think you didn't get the question right.. I want to print the list for which the answer is 225 with that specific arrangement
3rd Aug 2019, 1:07 PM
Rohit Panchal
Rohit Panchal - avatar
0
~ swim ~ well it will just print the input list
3rd Aug 2019, 1:06 PM
Rohit Panchal
Rohit Panchal - avatar