+ 46

CHALLENGE : INTEGERS CONCATENATE 💻⌨️🖱️

Given a set of 10 random positive integers (in range 1-100), write a code to concatenate the integers in such a way that the concatenation of the numbers gives the smallest possible integer. Show us original list of integers and smallest number. Example: List: 78, 52, 5, 98, 42, 21, 9, 67, 18, 6 Smallest number : 18214252566778989 https://code.sololearn.com/cjsn73KEE51p/?ref=app

16th Jan 2018, 12:38 PM
LukArToDo
LukArToDo - avatar
37 Answers
+ 20
The sorting algorithm is a bit tricky. I hope, that my easy key is correct: The key is either the number, if it is 2-digit, otherwise 11*number So 31,36,3 31 -> 31 36 -> 36 3 -> 33 and the number is 31336. with that python takes it easy and @VcC will have no prob with a oneliner (-; https://code.sololearn.com/c55cGt2GJQcK
16th Jan 2018, 3:16 PM
Oma Falk
Oma Falk - avatar
16th Jan 2018, 5:23 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 17
https://code.sololearn.com/c0V7G3VObzAS/?ref=app
27th Jan 2018, 8:12 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
16th Jan 2018, 11:48 AM
Paul
Paul - avatar
+ 14
My submission in ES6: [ Update ] Debugged the errors! https://code.sololearn.com/WIuUhJ9JVpPQ/?ref=app
16th Jan 2018, 12:59 PM
777
777 - avatar
+ 12
My code, works perfectly with a mix of one and two digit integers: https://code.sololearn.com/c9Hbf5pVUrRW/#java
16th Jan 2018, 1:12 PM
István Ócsai
István Ócsai - avatar
+ 11
@Jonathan You have right, it is concatenate. 😉
16th Jan 2018, 12:22 PM
LukArToDo
LukArToDo - avatar
+ 10
My try, I am not sure if it is correct or not :) https://code.sololearn.com/c7G9G4mgzFDj/?ref=app
16th Jan 2018, 1:43 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 9
This is my trial with Python Help me in simplifying it... https://code.sololearn.com/ca1D0r9uXzAK/#py Thanks!
16th Jan 2018, 3:58 PM
Anto74
Anto74 - avatar
+ 8
Noooo, I thought I would be the first... xD https://code.sololearn.com/cKPi26E3x962/?ref=app
16th Jan 2018, 11:48 AM
Lucas Pardo
Lucas Pardo - avatar
17th Jan 2018, 8:35 AM
Käzî Mrîdùl Høssäîn
Käzî Mrîdùl Høssäîn - avatar
+ 8
I hope it is correct this time... (Ruby code) * https://code.sololearn.com/caVnvSh1mzmq/#rb
20th Jan 2018, 1:56 PM
noobcøder
noobcøder - avatar
+ 7
@cool codin your algorithm has a prob with one digit numbers please Test 3,31,35 good is 31335 better than 31353
16th Jan 2018, 2:59 PM
Oma Falk
Oma Falk - avatar
16th Jan 2018, 7:53 PM
bedawang
bedawang - avatar
+ 6
My shortest solution in JavaScript Edit : I have fixed the issue with single digits. http://code.sololearn.com/W1jFtUFjYhSI/?ref=app
16th Jan 2018, 11:59 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 6
@Ferhat it works perfectly if you only have two-digit numbers. has a problem if threre are one-digits.
16th Jan 2018, 3:26 PM
Oma Falk
Oma Falk - avatar
17th Jan 2018, 1:47 PM
David Akhihiero
David Akhihiero - avatar
17th Jan 2018, 5:17 PM
Marfik Em
Marfik Em - avatar
+ 5
I have learned some skills from @lukartodo https://code.sololearn.com/ckiBJ0i61ubl/?ref=app
16th Jan 2018, 7:08 PM
abdulazizumarovich
abdulazizumarovich - avatar
+ 5
Here is my try in java , it can give the smallest no. which can be formed for any set of positive no.s and any range. It was a tough one 😅 and little bit tricky. To input 10 no.s just input 10 , then your 10 no.s , it will give the smallest no. which can be formed. https://code.sololearn.com/cwGkATLT2IX9/?ref=app
21st Jan 2018, 12:19 PM
Mr.Curious
Mr.Curious - avatar