+ 180

[ASSIGNMENT] Arrange the Strings!

Challenge: Arrange the strings! by: Persona Description: Your task is to sort a given string. Each word in the String will contain a single number. This number is the position the word should have in the result. Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). If the input String is empty, return an empty String. The words in the input String will only contain valid consecutive numbers. For an input: "is2 Thi1s T4est 3a" the function should return "Thi1s is2 3a T4est"

21st Dec 2017, 1:38 PM
PERSONA
PERSONA - avatar
223 Answers
+ 118
Challenge accepted Like this??? Edit: Thank you for the upvotes and also for the comments, thanks for pointing out the weaknesses of my code for me to correct and also for praising the nice work😉😁 that was done . I could say that it all improved me 👊👊👍👍. https://code.sololearn.com/cerJ9QGv1lCA/?ref=app
21st Dec 2017, 2:15 PM
Justine Ogaraku
Justine Ogaraku - avatar
21st Dec 2017, 6:02 PM
LukArToDo
LukArToDo - avatar
+ 36
https://code.sololearn.com/cT2zJr3S4S7o/?ref=app
21st Dec 2017, 4:09 PM
Käzî Mrîdùl Høssäîn
Käzî Mrîdùl Høssäîn - avatar
21st Dec 2017, 6:36 PM
Luc Hariman Randrianomenjanahary
Luc Hariman Randrianomenjanahary - avatar
+ 25
22nd Dec 2017, 8:55 AM
noobcøder
noobcøder - avatar
23rd Dec 2017, 8:27 PM
David Akhihiero
David Akhihiero - avatar
+ 25
Here's mine finished. I'm still learning Java, so it's not as short as some of these: https://code.sololearn.com/c3C6TWBBXo3W/#java
24th Dec 2017, 10:59 PM
MaddyChan
MaddyChan - avatar
+ 24
https://code.sololearn.com/cBsbnuKMVKt2/?ref=app
23rd Dec 2017, 7:14 PM
David Ashton
David Ashton - avatar
+ 21
Here's my C# implementation! ✌ LINQ One-Liner〰 words.Select(w => new { Word = w, Order = Regex.Match(w, @"(\d)").Value }) .OrderBy(p => p.Order) .Select(p => p.Word) It has been a really long time I didn't submit LINQ solution and I hope you all enjoy it! Happy Christmas Eve to everyone~ 😄 https://code.sololearn.com/cud7sJqhMlNR/?ref=app
24th Dec 2017, 4:56 AM
Zephyr Koo
Zephyr Koo - avatar
+ 20
https://code.sololearn.com/cYS0CiaJnAZe/?ref=app
22nd Dec 2017, 5:00 AM
MrCoder
MrCoder - avatar
+ 18
Here's my approach to my challenge: https://code.sololearn.com/c81U2IH4Xrz9/?ref=app
21st Dec 2017, 3:23 PM
PERSONA
PERSONA - avatar
+ 17
Hmm.. Something different than usual string challenges
21st Dec 2017, 5:58 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 17
Just learned Regular Expressions, so I wanted to try to use them in this challenge. Here is my answer (Python) : https://code.sololearn.com/csYzu4GioQZd import re a = input().split() for i in range(len(a)): print(*[elem for elem in a if re.search(str(i+1), elem)], end=' ')
23rd Dec 2017, 5:33 PM
Sina Seirafi
Sina Seirafi - avatar
+ 17
This is solution via JavaScript😊 https://code.sololearn.com/WTA1hrwaJYfV/?ref=app
24th Dec 2017, 9:07 AM
Богун Владислав Николаевич
Богун Владислав Николаевич - avatar
22nd Dec 2017, 1:40 PM
Jonathan Álex
Jonathan Álex - avatar
+ 16
// JS Code var words = prompt("Enter some words", "is2 Thi1s T4est 3a").split(" "); var updated = []; //console.log(words) for(var i = 0; i < words.length; i++){ for(var j = 0; j < words[i].length; j++){ if(words[i][j] <= '9' && words[i][j] >= '0'){ updated[words[i][j]] = words[i]; } } } reswords = updated.join(" "); console.log(reswords); // Challenge #1
23rd Dec 2017, 3:54 PM
777
777 - avatar
+ 16
First C++ submission, using C++11. Does exactly what it should. https://code.sololearn.com/cMctkpPtTgJd/?ref=app
23rd Dec 2017, 3:59 PM
Timon Paßlick
+ 15
small, simple & readable 😉 Edit: Ruby code added (24/12/2017) https://code.sololearn.com/c2OT65dQ9WlJ/?ref=app https://code.sololearn.com/cNf55Ae3sHGS/?ref=app
23rd Dec 2017, 6:34 PM
OR!ON 🛡️
OR!ON 🛡️ - avatar
+ 14
Will do it as soon as I'm on PC
21st Dec 2017, 2:05 PM
Riaz
Riaz - avatar