+ 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
36 Antworten
+ 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
+ 17
Nice challenge LukArToDo.
https://code.sololearn.com/c6aeEGI8jcQ4/?ref=app
+ 17
https://code.sololearn.com/c0V7G3VObzAS/?ref=app
+ 14
This is my code:
https://code.sololearn.com/cl8HeVjVswAh/?ref=app
+ 14
My submission in ES6:
[ Update ] Debugged the errors!
https://code.sololearn.com/WIuUhJ9JVpPQ/?ref=app
+ 12
My code, works perfectly with a mix of one and two digit integers:
https://code.sololearn.com/c9Hbf5pVUrRW/#java
+ 11
@Jonathan
You have right, it is concatenate. 😉
+ 10
My try, I am not sure if it is correct or not :)
https://code.sololearn.com/c7G9G4mgzFDj/?ref=app
+ 9
This is my trial with Python
Help me in simplifying it...
https://code.sololearn.com/ca1D0r9uXzAK/#py
Thanks!
+ 8
Noooo, I thought I would be the first... xD
https://code.sololearn.com/cKPi26E3x962/?ref=app
+ 8
it works for 1-99 numbers..
https://code.sololearn.com/cH1O65kIdubw/?ref=app
+ 8
I hope it is correct this time... (Ruby code)
* https://code.sololearn.com/caVnvSh1mzmq/#rb
+ 7
@cool codin
your algorithm has a prob with one digit numbers
please Test 3,31,35
good is 31335
better than 31353
+ 6
My shortest solution in JavaScript
Edit : I have fixed the issue with single digits.
http://code.sololearn.com/W1jFtUFjYhSI/?ref=app
+ 6
@Ferhat it works perfectly if you only have two-digit numbers.
has a problem if threre are one-digits.
+ 6
A compact version: 😁
https://code.sololearn.com/c84KnVhcsu2R/?ref=app
+ 5
I have learned some skills from @lukartodo
https://code.sololearn.com/ckiBJ0i61ubl/?ref=app
+ 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