šŸ† [MšŸ’™ Challenge] Substring Reversal | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 14

šŸ† [MšŸ’™ Challenge] Substring Reversal

Monday Blue šŸ’™ Challenge Series #1 Write a program to accept both { string } and { length } to perform reverse on each of the substrings of the given length. Here are the test cases of "123456789":- ā˜‘ Length 1 output: "123456789" ā˜‘ Length 2 output: " 214365879" ā˜‘ Length 3 output: "321654987" Assumption: 1 ā‰¤ length ā‰¤ string's length Happy Coding!!! šŸ˜šŸ’»

16th Oct 2017, 1:29 PM
Zephyr Koo
Zephyr Koo - avatar
20 Respostas
+ 10
18th Sep 2017, 4:56 AM
noobcĆøder
noobcĆøder - avatar
+ 11
@ysraelcon Another creative use of regex! You reminds me about the comic strip by xkcd below and it seems almost anything can be solved by regex. šŸ˜‚ By ysraelcon šŸ‘‡šŸ‘ https://code.sololearn.com/WP35CG6WZ66D/?ref=app https://code.sololearn.com/WiBHxBs0BFmX/?ref=app
18th Sep 2017, 11:59 AM
Zephyr Koo
Zephyr Koo - avatar
+ 11
https://code.sololearn.com/cmf0LR6eXRiw/#cs My solution in C# :) .
19th Sep 2017, 12:22 AM
Vukan
Vukan - avatar
+ 8
heres mine... prints all possibility ## https://code.sololearn.com/cdLqa08Oh7d7/?ref=app
18th Sep 2017, 3:26 AM
sayan chandra
sayan chandra - avatar
+ 6
@Calvin Good job! We need a general approach to accept any length of substring with the constraint above by using one function only. I believe you can do it! šŸ˜„
18th Sep 2017, 11:33 AM
Zephyr Koo
Zephyr Koo - avatar
+ 6
Here's my own C# implementation! āœŒ LINQ One-Liner怰 string.Concat( Enumerable.Range(0, input.Length) .GroupBy(i => i / length) .Select(g => string.concat( g.Select(i => input[i]) .Reverse()))) Yup it's a LINQ solution again~ Enjoy! ā¤ https://code.sololearn.com/c3QVlZ739VTl/?ref=app
16th Oct 2017, 2:42 PM
Zephyr Koo
Zephyr Koo - avatar
+ 5
https://code.sololearn.com/WPA0zG5EI6i7/?ref=app
18th Sep 2017, 3:36 AM
CalviÕ²
CalviÕ² - avatar
+ 5
@Zephyr: Thanks for mark mine as best answer! šŸ˜ŠšŸ‘
16th Oct 2017, 5:08 PM
noobcĆøder
noobcĆøder - avatar
+ 5
@noobcĆøder You're welcome! šŸ˜„ Well the best answer was selected after every week, perhaps you're too busy to get notified about it. šŸ˜‚ Glad that there are people still interested with the challenge since I BUMP it unintentionally by standardizing the tags across my post. Thank you everyone again! šŸ‘
17th Oct 2017, 1:39 AM
Zephyr Koo
Zephyr Koo - avatar
+ 4
my one https://code.sololearn.com/WP35CG6WZ66D/?ref=app example: text: Sololearn nro: 3 output: loSelonra
18th Sep 2017, 6:18 AM
ysraelcon
ysraelcon - avatar
18th Sep 2017, 1:12 PM
Zizibee
+ 4
My second solution in python. A bit longer but much better to anderstand: https://code.sololearn.com/csd9zxe2cyt2/?ref=app
18th Sep 2017, 1:31 PM
Zizibee
18th Sep 2017, 4:56 PM
VcC
VcC - avatar
18th Sep 2017, 1:17 PM
Jhoniel Viloria
Jhoniel Viloria - avatar
+ 3
Here You go in Java. Checks for valid length input. https://code.sololearn.com/cpwnmPxC5VtV/?ref=app
29th Sep 2017, 10:14 PM
Vari93
Vari93 - avatar
+ 3
https://code.sololearn.com/cMEgzsZh8s8L/?ref=app
16th Oct 2017, 2:11 PM
Kartikey Sahu
Kartikey Sahu - avatar
+ 1
I will try
16th Oct 2017, 2:28 PM
Sayantan Sinharay
Sayantan Sinharay - avatar
16th Oct 2017, 6:52 PM
VcC
VcC - avatar
20th Oct 2017, 3:18 PM
āµ¢ā“·āµ¢ā“·
āµ¢ā“·āµ¢ā“· - avatar
- 1
HERES A NEW CHALLENGE CHECK IT AND TRY IF YOU WANT https://www.sololearn.com/discuss/793924/?ref=app
17th Oct 2017, 3:14 PM
sayan chandra
sayan chandra - avatar