+ 15

[ASSIGNMENT] Reverse String๐Ÿšฉ๐Ÿšฉ

Task: take input from user. Then, reverse it using any method. Example: input: solo output: olos input: say output: yas You can use any language to perform this task. I already submitted this challenge to Lesson Factory. https://code.sololearn.com/cpAv2CZejx67/?ref=app

6th Apr 2018, 10:24 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
27 Answers
+ 24
https://code.sololearn.com/c3luPGo2uDq3/?ref=app
6th Apr 2018, 11:59 AM
Danijel Ivanoviฤ‡
Danijel Ivanoviฤ‡ - avatar
+ 24
<!-- My try in PHP โœŒ๏ธ๐Ÿ‘ ๐Ÿ˜Ž Unfortunately can't take user input (1 Liner) ๐Ÿ˜‰๐Ÿ˜‰๐Ÿ˜‰ --> <?php $str = "solo"; echo "Input : $str<br>"."Output: ".strrev($str); ?>
6th Apr 2018, 1:24 PM
๐ŸŒ›DT๐ŸŒœ
๐ŸŒ›DT๐ŸŒœ - avatar
+ 23
Muhammad Khairul Amirin Bin Yaacob ๐Ÿ˜€๐Ÿ˜๐Ÿ˜„๐Ÿ‘Thank you very much, ๐Ÿ˜†๐Ÿค— I'm really honored, surprised and delighted!! ๐Ÿ˜€๐Ÿ˜๐Ÿ˜„๐Ÿค˜ I'm glad you like my answer and I'm thrilled that you have chosen my answer for The Best! โ˜บ๐Ÿ˜†๐Ÿ˜Š Thanks a lot ๐Ÿ˜‰๐Ÿ‘
7th Apr 2018, 6:23 AM
Danijel Ivanoviฤ‡
Danijel Ivanoviฤ‡ - avatar
+ 11
Python - print(input()[::-1]) JS - document.write(prompt().split("").reverse().join(""))
6th Apr 2018, 2:37 PM
Nikhil
Nikhil - avatar
6th Apr 2018, 10:43 AM
Baraa AB
Baraa AB - avatar
+ 8
one liner in js console.log(prompt("Enter any word").split("").reverse().join(""));
6th Apr 2018, 11:27 AM
แ Œแ ŒCode X
แ Œแ ŒCode X - avatar
+ 7
6th Apr 2018, 11:39 AM
Louis
Louis - avatar
+ 7
Nice Game ;-) Functional programming! Use spread operator ES6 function reverseString(s){ return [...s].reverse().join("");} Use arrow functions and reduce in ES6 function reverseString(s){ return [...s].reduceRight( (prev, curr) => prev + curr );} Use ES6 Ternery operator and recursion function reverseString(s){return (s === '') ? '' : reverseString(s.substr(1)) + s.charAt(0); }
6th Apr 2018, 3:02 PM
Mike Choy
Mike Choy - avatar
7th Apr 2018, 12:16 PM
Uni
Uni - avatar
+ 6
There is more than one way to do this: https://code.sololearn.com/c0NFcB1dD5Yu/?ref=app
6th Apr 2018, 3:30 PM
Paul
Paul - avatar
6th Apr 2018, 5:45 PM
Shobikaj
Shobikaj - avatar
7th Apr 2018, 12:51 PM
Uni
Uni - avatar
6th Apr 2018, 10:37 AM
Bishal Sarang
Bishal Sarang - avatar
+ 5
Just use string method reverse().
6th Apr 2018, 10:42 AM
Warith Vatanaplachaigoon
Warith Vatanaplachaigoon - avatar
+ 4
In C++, just use std::reverse to do the work for you.
6th Apr 2018, 10:39 AM
Timon PaรŸlick
6th Apr 2018, 10:41 AM
Warith Vatanaplachaigoon
Warith Vatanaplachaigoon - avatar
6th Apr 2018, 1:44 PM
Aaron Stone
Aaron Stone - avatar
+ 4
one liner in python: print (input ()[::-1])
6th Apr 2018, 3:53 PM
Mitali
Mitali - avatar
7th Apr 2018, 12:23 PM
Warith Vatanaplachaigoon
Warith Vatanaplachaigoon - avatar
6th Apr 2018, 2:10 PM
gurpreet kapoor
gurpreet kapoor - avatar