[ ASSIGNMENT: ] Form The Minimum [ UPDATE: ] Form The minValue Without Leading Zero! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 29

[ ASSIGNMENT: ] Form The Minimum [ UPDATE: ] Form The minValue Without Leading Zero!

TASK : Given a list of digits,  return the smallest number that could be formed from these digits, using the digits only once (ignore duplicates). NOTE : Only positive integers will be passed to the method (> 0 ), no negatives, Without duplications! Input, Output Examples :: 1. minValue({5, 7, 5, 9, 7}) --> return (579) (579) is the minimum number could be formed! 2. minValue({4, 1, 3, 1, 0, 0, 1}) --> return (1034) (1034) is the minimum number could be formed! HappyCodings!:-) Thanks to LukArToDo

2nd May 2018, 9:28 AM
Danijel Ivanović
Danijel Ivanović - avatar
15 Answers
3rd May 2018, 10:47 AM
🌛DT🌜
🌛DT🌜 - avatar
+ 18
Bravo!! LukArToDo 😀👏👏😄 My Friend, I think, now the task is Ok! 👌😉 Thank you very much for your Update and huge support which I have from You! 👍😊
2nd May 2018, 2:24 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 16
Danijel Ivanović You're welcome my friend. Thank you for the nice challenge 😉
2nd May 2018, 2:25 PM
LukArToDo
LukArToDo - avatar
+ 10
My version; space separated digits required as input. As a extra bonus, tossed in the maximum too. https://code.sololearn.com/ckirPIbUbjhO
2nd May 2018, 10:10 PM
John Wells
John Wells - avatar
2nd May 2018, 11:53 AM
cyk
cyk - avatar
+ 8
This is a well commented version on Python: https://code.sololearn.com/c8Yc4X3nm2aI/?ref=app And this is a Python oneliner based on it: https://code.sololearn.com/czR1aU1HqS73/?ref=app UPD: One more Python oneliner (2 lines in fact) based on @cyk solution. Complexity is much higher, but visually it is more pretty: https://code.sololearn.com/cF580t646eMw/?ref=app
3rd May 2018, 3:27 AM
Nevfy
+ 6
This one is pretty tricky but I was waiting for it so I made it in Ruby but it will by harder for me in other languages but I'll still give it a try 😉 Added the maximum number as a bonus😉👍 Updated. https://code.sololearn.com/cM59PwSL43uy/?ref=app https://code.sololearn.com/WV8dvoexIv9F/?ref=app
2nd May 2018, 9:43 PM
Uni
Uni - avatar
+ 6
@Louis 1. sorted() already returns a list, so there is no need for further conversion. 2. No need to convert result to int before printing out. print() will convert it back to string. So the shortest Python oneliner could be just: print(''.join(sorted(set(list(input()))))) But it will not work properly with the second example in challenge description. See this code where this issue is solved: https://code.sololearn.com/czR1aU1HqS73/?ref=app BTW, if you have better ideas to make it shorter, you are welcome :-)
3rd May 2018, 3:39 AM
Nevfy
2nd May 2018, 12:32 PM
hinanawi
hinanawi - avatar
+ 5
#Python # When asked - enter the number - as in:57597 output will be 579 print(int(''.join(list(sorted(set(list(input())))))))
2nd May 2018, 12:36 PM
Louis
Louis - avatar
+ 3
Danijel Ivanović updated my code to filter out any possible leading 0
3rd May 2018, 5:54 AM
hinanawi
hinanawi - avatar
0
hiii
4th May 2018, 11:46 AM
rajesh kumar
0
ti
9th May 2018, 1:08 PM
ksortinh
- 2
coc gems 10000000000
3rd May 2018, 6:40 AM
Raja Pandi
Raja Pandi - avatar