+ 4
CHALLENGE: randomize words of a sentence
Take a sentence as a input. Randomize all its words separated by'/'. Example: INPUT: I love you, you love me; you know it. OUTPUT: I/you/it./love/know/you,/me;/love./you
6 ответов
+ 11
https://code.sololearn.com/cUFi1qQYEU0Y/?ref=app
+ 6
My try in js
https://code.sololearn.com/W0LpjKW9xpm1/?ref=app
+ 6
with Math.random()
not perfect randomizer
https://code.sololearn.com/ccKBHtn4aTUB/?ref=app
+ 2
Thanks to everyone, I am a newbie here, and I'm so glad to be here.
Learnt a lot from your codes.
This is a simple problems that involves shuffling an array or list. Many of you have used built-in methods for it, that's totally fine. Where ever it comes to shuffling, I never hesitate to use Fisher-Yates algorithm, it's much efficient. I think those built-in methods use it too behind the scene.
Here is the code, it's written in javascript though.
https://code.sololearn.com/WuMoA5x2JVxl/?ref=app